[poppler] poppler/Annot.cc poppler/Annot.h
Inigo Martinez
inigomartinez at kemper.freedesktop.org
Sat Apr 12 16:46:43 PDT 2008
poppler/Annot.cc | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
poppler/Annot.h | 37 ++++++++++++++++++++
2 files changed, 136 insertions(+)
New commits:
commit 9311f75d4c3da991efb8afd00701a0ce1cbae1b0
Author: Iñigo MartÃnez <inigomartinez at gmail.com>
Date: Sun Apr 13 01:52:36 2008 +0200
Almost full AnnotPolygon support.
Signed-off-by: Iñigo MartÃnez <inigomartinez at gmail.com>
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 65cabb1..40ef6f6 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -175,6 +175,11 @@ AnnotBorderEffect::AnnotBorderEffect(Dict *dict) {
// AnnotPath
//------------------------------------------------------------------------
+AnnotPath::AnnotPath() {
+ coords = NULL;
+ coordsLength = 0;
+}
+
AnnotPath::AnnotPath(Array *array) {
coords = NULL;
coordsLength = 0;
@@ -3450,6 +3455,100 @@ void AnnotGeometry::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
}
//------------------------------------------------------------------------
+// AnnotPolygon
+//------------------------------------------------------------------------
+
+AnnotPolygon::AnnotPolygon(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
+ AnnotMarkup(xrefA, dict, catalog, obj) {
+ // the real type will be read in initialize()
+ type = typePolygon;
+ initialize(xrefA, catalog, dict);
+}
+
+AnnotPolygon::~AnnotPolygon() {
+ delete vertices;
+
+ if (interiorColor)
+ delete interiorColor;
+
+ if (borderEffect)
+ delete borderEffect;
+}
+
+void AnnotPolygon::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
+ Object obj1;
+
+ if (dict->lookup("Subtype", &obj1)->isName()) {
+ GooString typeName(obj1.getName());
+ if (!typeName.cmp("Polygon")) {
+ type = typePolygon;
+ } else if (!typeName.cmp("PolyLine")) {
+ type = typePolyLine;
+ }
+ }
+ obj1.free();
+
+ if (dict->lookup("Vertices", &obj1)->isArray()) {
+ vertices = new AnnotPath(obj1.getArray());
+ } else {
+ vertices = new AnnotPath();
+ error(-1, "Bad Annot Polygon Vertices");
+ ok = gFalse;
+ }
+ obj1.free();
+
+ if (dict->lookup("LE", &obj1)->isArray() && obj1.arrayGetLength() == 2) {
+ Object obj2;
+
+ if(obj1.arrayGet(0, &obj2)->isString())
+ startStyle = parseAnnotLineEndingStyle(obj2.getString());
+ else
+ startStyle = annotLineEndingNone;
+ obj2.free();
+
+ if(obj1.arrayGet(1, &obj2)->isString())
+ endStyle = parseAnnotLineEndingStyle(obj2.getString());
+ else
+ endStyle = annotLineEndingNone;
+ obj2.free();
+
+ } else {
+ startStyle = endStyle = annotLineEndingNone;
+ }
+ obj1.free();
+
+ if (dict->lookup("IC", &obj1)->isArray()) {
+ interiorColor = new AnnotColor(obj1.getArray());
+ } else {
+ interiorColor = NULL;
+ }
+ obj1.free();
+
+ if (dict->lookup("BE", &obj1)->isDict()) {
+ borderEffect = new AnnotBorderEffect(obj1.getDict());
+ } else {
+ borderEffect = NULL;
+ }
+ obj1.free();
+
+ if (dict->lookup("IT", &obj1)->isName()) {
+ GooString *intentName = new GooString(obj1.getName());
+
+ if(!intentName->cmp("PolygonCloud")) {
+ intent = polygonCloud;
+ } else if(!intentName->cmp("PolyLineDimension")) {
+ intent = polylineDimension;
+ } else {
+ intent = polygonDimension;
+ }
+ delete intentName;
+ } else {
+ intent = polygonCloud;
+ }
+ obj1.free();
+}
+
+//------------------------------------------------------------------------
// AnnotCaret
//------------------------------------------------------------------------
diff --git a/poppler/Annot.h b/poppler/Annot.h
index dab63f5..fe951cf 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -67,6 +67,7 @@ protected:
class AnnotPath {
public:
+ AnnotPath();
AnnotPath(Array *array);
AnnotPath(AnnotCoord **coords, int coordLength);
~AnnotPath();
@@ -973,6 +974,42 @@ private:
};
//------------------------------------------------------------------------
+// AnnotPolygon
+//------------------------------------------------------------------------
+
+class AnnotPolygon: public AnnotMarkup {
+public:
+
+ enum AnnotPolygonIntent {
+ polygonCloud, // PolygonCloud
+ polylineDimension, // PolyLineDimension
+ polygonDimension // PolygonDimension
+ };
+
+ AnnotPolygon(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
+ ~AnnotPolygon();
+
+ // getters
+
+private:
+
+ void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
+
+ // required
+ AnnotPath *vertices; // Vertices
+
+ // optional
+ AnnotLineEndingStyle startStyle; // LE (Default [/None /None])
+ AnnotLineEndingStyle endStyle; //
+ // inherited from Annot
+ // AnnotBorderBS border; // BS
+ AnnotColor *interiorColor; // IC
+ AnnotBorderEffect *borderEffect; // BE
+ AnnotPolygonIntent intent; // IT
+ // Measure
+};
+
+//------------------------------------------------------------------------
// AnnotCaret
//------------------------------------------------------------------------
More information about the poppler
mailing list