Commit ffe09454 authored by Inigo Martínez's avatar Inigo Martínez

Initial Annot3D parsing a few general improvements.

Signed-off-by: Inigo Martínez's avatarIñigo Martínez <inigomartinez@gmail.com>
parent 8757c577
......@@ -184,20 +184,20 @@ AnnotPath::AnnotPath(AnnotCoord **coords, int coordsLength) {
}
}
double AnnotPath::getX(int coord) {
if (coord > 0 && coord < coordsLength)
double AnnotPath::getX(int coord) const {
if (coord >= 0 && coord < coordsLength)
return coords[coord]->getX();
return 0;
}
double AnnotPath::getY(int coord) {
if (coord > 0 && coord < coordsLength)
double AnnotPath::getY(int coord) const {
if (coord >= 0 && coord < coordsLength)
return coords[coord]->getY();
return 0;
}
AnnotCoord *AnnotPath::getCoord(int coord) {
if (coord > 0 && coord < coordsLength)
AnnotCoord *AnnotPath::getCoord(int coord) const {
if (coord >= 0 && coord < coordsLength)
return coords[coord];
return NULL;
}
......@@ -1167,7 +1167,7 @@ void AnnotMarkup::initialize(XRef *xrefA, Dict *dict, Catalog *catalog, Object *
date = NULL;
}
obj1.free();
if (dict->lookup("IRT", &obj1)->isDict()) {
inReplyTo = obj1.getDict();
} else {
......@@ -3552,6 +3552,120 @@ void AnnotFileAttachment::initialize(XRef *xrefA, Catalog *catalog, Dict* dict)
obj1.free();
}
//------------------------------------------------------------------------
// Annot3D
//------------------------------------------------------------------------
Annot3D::Annot3D(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
Annot(xrefA, dict, catalog, obj) {
type = type3D;
initialize(xrefA, catalog, dict);
}
Annot3D::~Annot3D() {
if (activation)
delete activation;
}
void Annot3D::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
Object obj1;
if (dict->lookup("3DA", &obj1)->isDict()) {
activation = new Activation(obj1.getDict());
} else {
activation = NULL;
}
obj1.free();
}
Annot3D::Activation::Activation(Dict *dict) {
Object obj1;
if (dict->lookup("A", &obj1)->isName()) {
GooString *name = new GooString(obj1.getName());
if(!name->cmp("PO")) {
aTrigger = aTriggerPageOpened;
} else if(!name->cmp("PV")) {
aTrigger = aTriggerPageVisible;
} else if(!name->cmp("XA")) {
aTrigger = aTriggerUserAction;
} else {
aTrigger = aTriggerUnknown;
}
delete name;
} else {
aTrigger = aTriggerUnknown;
}
obj1.free();
if(dict->lookup("AIS", &obj1)->isName()) {
GooString *name = new GooString(obj1.getName());
if(!name->cmp("I")) {
aState = aStateEnabled;
} else if(!name->cmp("L")) {
aState = aStateDisabled;
} else {
aState = aStateUnknown;
}
delete name;
} else {
aState = aStateUnknown;
}
obj1.free();
if(dict->lookup("D", &obj1)->isName()) {
GooString *name = new GooString(obj1.getName());
if(!name->cmp("PC")) {
dTrigger = dTriggerPageClosed;
} else if(!name->cmp("PI")) {
dTrigger = dTriggerPageInvisible;
} else if(!name->cmp("XD")) {
dTrigger = dTriggerUserAction;
} else {
dTrigger = dTriggerUnknown;
}
delete name;
} else {
dTrigger = dTriggerUnknown;
}
obj1.free();
if(dict->lookup("DIS", &obj1)->isName()) {
GooString *name = new GooString(obj1.getName());
if(!name->cmp("U")) {
dState = dStateUninstantiaded;
} else if(!name->cmp("I")) {
dState = dStateInstantiated;
} else if(!name->cmp("L")) {
dState = dStateLive;
} else {
dState = dStateUnknown;
}
delete name;
} else {
dState = dStateUnknown;
}
obj1.free();
if (dict->lookup("TB", &obj1)->isBool()) {
displayToolbar = obj1.getBool();
} else {
displayToolbar = gTrue;
}
obj1.free();
if (dict->lookup("NP", &obj1)->isBool()) {
displayNavigation = obj1.getBool();
} else {
displayNavigation = gFalse;
}
obj1.free();
}
//------------------------------------------------------------------------
// Annots
//------------------------------------------------------------------------
......@@ -3645,7 +3759,7 @@ Annot *Annots::createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj
} else if (!typeName->cmp("Watermark")) {
annot = new Annot(xref, dict, catalog, obj);
} else if (!typeName->cmp("3D")) {
annot = new Annot(xref, dict, catalog, obj);
annot = new Annot3D(xref, dict, catalog, obj);
} else {
annot = new Annot(xref, dict, catalog, obj);
}
......
......@@ -68,9 +68,9 @@ class AnnotPath {
public:
AnnotPath(AnnotCoord **coords, int coordLength);
double getX(int coord);
double getY(int coord);
AnnotCoord *getCoord(int coord);
double getX(int coord) const;
double getY(int coord) const;
AnnotCoord *getCoord(int coord) const;
double getCoordsLength() const { return coordsLength; }
protected:
AnnotCoord **coords;
......@@ -154,7 +154,7 @@ class AnnotQuadrilaterals {
public:
AnnotQuadrilaterals(Array *array, PDFRectangle *rect);
virtual ~AnnotQuadrilaterals();
~AnnotQuadrilaterals();
double getX1(int quadrilateral);
double getY1(int quadrilateral);
......@@ -217,8 +217,8 @@ public:
AnnotBorderArray();
AnnotBorderArray(Array *array);
virtual double getHorizontalCorner() const { return horizontalCorner; }
virtual double getVerticalCorner() const { return verticalCorner; }
double getHorizontalCorner() const { return horizontalCorner; }
double getVerticalCorner() const { return verticalCorner; }
protected:
static const int DASH_LIMIT = 10; // implementation note 82 in Appendix H.
......@@ -534,7 +534,7 @@ protected:
class AnnotPopup: public Annot {
public:
AnnotPopup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
virtual ~AnnotPopup();
~AnnotPopup();
Dict *getParent() const { return parent; }
GBool getOpen() const { return open; }
......@@ -809,7 +809,7 @@ public:
};
AnnotFreeText(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
virtual ~AnnotFreeText();
~AnnotFreeText();
// getters
GooString *getAppearanceString() const { return appearanceString; }
......@@ -860,7 +860,7 @@ public:
};
AnnotLine(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
virtual ~AnnotLine();
~AnnotLine();
// getters
AnnotLineEndingStyle getStartStyle() const { return startStyle; }
......@@ -1005,8 +1005,8 @@ public:
~AnnotInk();
// getters
virtual AnnotPath **getInkList() const { return inkList; }
virtual int getInkListLength() const { return inkListLength; }
AnnotPath **getInkList() const { return inkList; }
int getInkListLength() const { return inkListLength; }
private:
......@@ -1033,8 +1033,8 @@ public:
~AnnotFileAttachment();
// getters
virtual Object *getFile(Object *obj) { return file.fetch(xref, obj); }
virtual GooString *getName() const { return name; }
Object *getFile(Object *obj) { return file.fetch(xref, obj); }
GooString *getName() const { return name; }
private:
......@@ -1102,6 +1102,64 @@ private:
GBool regen;
};
//------------------------------------------------------------------------
// Annot3D
//------------------------------------------------------------------------
class Annot3D: public Annot {
class Activation {
public:
enum ActivationATrigger {
aTriggerUnknown,
aTriggerPageOpened, // PO
aTriggerPageVisible, // PV
aTriggerUserAction // XA
};
enum ActivationAState {
aStateUnknown,
aStateEnabled, // I
aStateDisabled // L
};
enum ActivationDTrigger {
dTriggerUnknown,
dTriggerPageClosed, // PC
dTriggerPageInvisible, // PI
dTriggerUserAction // XD
};
enum ActivationDState {
dStateUnknown,
dStateUninstantiaded, // U
dStateInstantiated, // I
dStateLive // L
};
Activation(Dict *dict);
private:
ActivationATrigger aTrigger; // A (Default XA)
ActivationAState aState; // AIS (Default L)
ActivationDTrigger dTrigger; // D (Default PI)
ActivationDState dState; // DIS (Default U)
GBool displayToolbar; // TB (Default true)
GBool displayNavigation; // NP (Default false);
};
public:
Annot3D(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
~Annot3D();
// getters
private:
void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
Activation *activation; // 3DA
};
//------------------------------------------------------------------------
// Annots
//------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment