[poppler] poppler/Annot.cc poppler/Annot.h

Inigo Martinez inigomartinez at kemper.freedesktop.org
Tue Apr 8 14:35:09 PDT 2008


 poppler/Annot.cc |   64 +++++++++++++++++----------------------------------
 poppler/Annot.h  |   69 +++++++++++++++++++++++++------------------------------
 2 files changed, 54 insertions(+), 79 deletions(-)

New commits:
commit 5f60843824582ece36d806508ec388330ddee854
Author: Iñigo Martínez <inigomartinez at gmail.com>
Date:   Tue Apr 8 00:30:57 2008 +0200

    Added AnnotCoord support.
    
    Signed-off-by: Iñigo Martínez <inigomartinez at gmail.com>

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 9f6b60e..1e82fd6 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -174,11 +174,8 @@ AnnotBorderEffect::AnnotBorderEffect(Dict *dict) {
 // AnnotCalloutLine
 //------------------------------------------------------------------------
 
-AnnotCalloutLine::AnnotCalloutLine(double x1, double y1, double x2, double y2) {
-  this->x1 = x1;
-  this->y1 = y1;
-  this->x2 = x2;
-  this->y2 = y2;
+AnnotCalloutLine::AnnotCalloutLine(double x1, double y1, double x2, double y2)
+    :  coord1(x1, y1), coord2(x2, y2) {
 }
 
 //------------------------------------------------------------------------
@@ -186,9 +183,8 @@ AnnotCalloutLine::AnnotCalloutLine(double x1, double y1, double x2, double y2) {
 //------------------------------------------------------------------------
 
 AnnotCalloutMultiLine::AnnotCalloutMultiLine(double x1, double y1, double x2,
-    double y2, double x3, double y3) : AnnotCalloutLine(x1, y1, x2, y2) {
-  this->x3 = x3;
-  this->y3 = y3;
+                                             double y2, double x3, double y3)
+    : AnnotCalloutLine(x1, y1, x2, y2), coord3(x3, y3) {
 }
 
 //------------------------------------------------------------------------
@@ -262,78 +258,55 @@ AnnotQuadrilaterals::~AnnotQuadrilaterals() {
 
 double AnnotQuadrilaterals::getX1(int quadrilateral) {
   if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
-    return quadrilaterals[quadrilateral]->x1;
+    return quadrilaterals[quadrilateral]->coord1.getX();
   return 0;
 }
 
 double AnnotQuadrilaterals::getY1(int quadrilateral) {
   if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
-    return quadrilaterals[quadrilateral]->y1;
+    return quadrilaterals[quadrilateral]->coord1.getY();
   return 0;
 }
 
 double AnnotQuadrilaterals::getX2(int quadrilateral) {
   if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
-    return quadrilaterals[quadrilateral]->x2;
+    return quadrilaterals[quadrilateral]->coord2.getX();
   return 0;
 }
 
 double AnnotQuadrilaterals::getY2(int quadrilateral) {
   if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
-    return quadrilaterals[quadrilateral]->y2;
+    return quadrilaterals[quadrilateral]->coord2.getY();
   return 0;
 }
 
 double AnnotQuadrilaterals::getX3(int quadrilateral) {
   if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
-    return quadrilaterals[quadrilateral]->x3;
+    return quadrilaterals[quadrilateral]->coord3.getX();
   return 0;
 }
 
 double AnnotQuadrilaterals::getY3(int quadrilateral) {
   if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
-    return quadrilaterals[quadrilateral]->y3;
+    return quadrilaterals[quadrilateral]->coord3.getY();
   return 0;
 }
 
 double AnnotQuadrilaterals::getX4(int quadrilateral) {
   if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
-    return quadrilaterals[quadrilateral]->x4;
+    return quadrilaterals[quadrilateral]->coord4.getX();
   return 0;
 }
 
 double AnnotQuadrilaterals::getY4(int quadrilateral) {
   if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
-    return quadrilaterals[quadrilateral]->y4;
+    return quadrilaterals[quadrilateral]->coord4.getY();
   return 0;
 }
 
 AnnotQuadrilaterals::AnnotQuadrilateral::AnnotQuadrilateral(double x1, double y1,
-        double x2, double y2, double x3, double y3, double x4, double y4) {
-  this->x1 = x1;
-  this->y1 = y1;
-  this->x2 = x2;
-  this->y2 = y2;
-  this->x3 = x3;
-  this->y3 = y3;
-  this->x4 = x4;
-  this->y4 = y4;
-}
-
-//------------------------------------------------------------------------
-// AnnotQuadPoints
-//------------------------------------------------------------------------
-
-AnnotQuadPoints::AnnotQuadPoints(double x1, double y1, double x2, double y2,
-    double x3, double y3, double x4, double y4) {
-  this->x1 = x1;
-  this->y1 = y1;
-  this->x2 = x2;
-  this->y2 = y2;
-  this->x3 = x3;
-  this->y3 = y3;
-  this->x4 = x4;
-  this->y4 = y4;
+    double x2, double y2, double x3, double y3, double x4, double y4)
+    : coord1(x1, y1), coord2(x2, y2), coord3(x3, y3), coord4(x4, y4) {
 }
 
 //------------------------------------------------------------------------
@@ -1530,6 +1503,9 @@ AnnotLine::AnnotLine(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
 }
 
 AnnotLine::~AnnotLine() {
+  delete coord1;
+  delete coord2;
+
   if (interiorColor)
     delete interiorColor;
 
@@ -1542,6 +1518,7 @@ void AnnotLine::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
 
   if (dict->lookup("L", &obj1)->isArray() && obj1.arrayGetLength() == 4) {
     Object obj2;
+    double x1, y1, x2, y2;
 
     (obj1.arrayGet(0, &obj2)->isNum() ? x1 = obj2.getNum() : x1 = 0);
     obj2.free();
@@ -1552,8 +1529,11 @@ void AnnotLine::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
     (obj1.arrayGet(3, &obj2)->isNum() ? y2 = obj2.getNum() : y2 = 0);
     obj2.free();
 
+    coord1 = new AnnotCoord(x1, y1);
+    coord2 = new AnnotCoord(x2, y2);
   } else {
-    x1 = y1 = x2 = y2 = 0;
+    coord1 = new AnnotCoord();
+    coord2 = new AnnotCoord();
   }
   obj1.free();
 
diff --git a/poppler/Annot.h b/poppler/Annot.h
index c821096..4001ab5 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -43,6 +43,24 @@ enum AnnotExternalDataType {
 };
 
 //------------------------------------------------------------------------
+// AnnotCoord
+//------------------------------------------------------------------------
+
+class AnnotCoord {
+public:
+
+  AnnotCoord() : x(0), y(0) { }
+  AnnotCoord(double _x, double _y) : x(_x), y(_y) { }
+
+  double getX() const { return x; }
+  double getY() const { return y; }
+  
+protected:
+
+  double x, y;
+};
+
+//------------------------------------------------------------------------
 // AnnotCalloutLine
 //------------------------------------------------------------------------
 
@@ -52,14 +70,14 @@ public:
   AnnotCalloutLine(double x1, double y1, double x2, double y2);
   virtual ~AnnotCalloutLine() { }
 
-  double getX1() const { return x1; }
-  double getY1() const { return y1; }
-  double getX2() const { return x2; }
-  double getY2() const { return y2; }
+  double getX1() const { return coord1.getX(); }
+  double getY1() const { return coord1.getY(); }
+  double getX2() const { return coord2.getX(); }
+  double getY2() const { return coord2.getY(); }
   
 protected:
 
-  double x1, y1, x2, y2;
+  AnnotCoord coord1, coord2;
 };
 
 //------------------------------------------------------------------------
@@ -72,12 +90,12 @@ public:
   AnnotCalloutMultiLine(double x1, double y1, double x2, double y2,
     double x3, double y3);
 
-  double getX3() const { return x3; }
-  double getY3() const { return y3; }
+  double getX3() const { return coord3.getX(); }
+  double getY3() const { return coord3.getY(); }
 
 protected:
 
-  double x3, y3;
+  AnnotCoord coord3;
 };
 
 //------------------------------------------------------------------------
@@ -113,7 +131,7 @@ class AnnotQuadrilaterals {
     AnnotQuadrilateral(double x1, double y1, double x2, double y2, double x3,
       double y3, double x4, double y4);
 
-    double x1, y1, x2, y2, x3, y3, x4, y4;
+    AnnotCoord coord1, coord2, coord3, coord4;
   };
 
 public:
@@ -137,29 +155,6 @@ protected:
 };
 
 //------------------------------------------------------------------------
-// AnnotQuadPoints
-//------------------------------------------------------------------------
-
-class AnnotQuadPoints {
-public:
-  
-  AnnotQuadPoints(double x1, double y1, double x2, double y2, double x3,
-      double y3, double x4, double y4);
-
-  double getX1() const { return x1; }
-  double getY1() const { return y1; }
-  double getX2() const { return x2; }
-  double getY2() const { return y2; }
-  double getX3() const { return x3; }
-  double getY3() const { return y3; }
-  double getX4() const { return x4; }
-  double getY4() const { return y4; }
-
-protected:
-  double x1, y1, x2, y2, x3, y3, x4, y4;
-};
-
-//------------------------------------------------------------------------
 // AnnotBorder
 //------------------------------------------------------------------------
 
@@ -863,17 +858,17 @@ public:
   Dict *getMeasure() const { return measure; }
   double getCaptionTextHorizontal() const { return captionTextHorizontal; }
   double getCaptionTextVertical() const { return captionTextVertical; }
-  double getX1() const { return x1; }
-  double getY1() const { return y1; }
-  double getX2() const { return x2; }
-  double getY2() const { return y2; }
+  double getX1() const { return coord1->getX(); }
+  double getY1() const { return coord1->getY(); }
+  double getX2() const { return coord2->getX(); }
+  double getY2() const { return coord2->getY(); }
 
 protected:
 
   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
 
   // required
-  double x1, y1, x2, y2;            // L
+  AnnotCoord *coord1, *coord2;
   
   // optional
   // inherited  from Annot


More information about the poppler mailing list