[poppler] 4 commits - poppler/Annot.cc poppler/Annot.h
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Thu Dec 5 08:48:35 PST 2013
poppler/Annot.cc | 369 +++++++++++++++++++++++++++++--------------------------
poppler/Annot.h | 23 ++-
2 files changed, 215 insertions(+), 177 deletions(-)
New commits:
commit e109cf2461d5be93d004593123d875a28fd79b61
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Tue Nov 26 20:12:22 2013 +0100
annots: Make Annot::setBorder receive an AnnotBorder object
Instead of receiving AnnotBorderArray. Also implement writeToObject in
both AnnotBorderArray and AnnotBorderBS to make sure that
Annot::setBorder will work for both cases.
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index b94039f..90a6e5d 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -614,10 +614,17 @@ void AnnotBorderArray::writeToObject(XRef *xref, Object *obj1) const {
Object obj2;
obj1->initArray(xref);
- obj1->arrayAdd(obj2.initReal( horizontalCorner ));
- obj1->arrayAdd(obj2.initReal( verticalCorner ));
- obj1->arrayAdd(obj2.initReal( width ));
- // TODO: Dash array
+ obj1->arrayAdd(obj2.initReal(horizontalCorner));
+ obj1->arrayAdd(obj2.initReal(verticalCorner));
+ obj1->arrayAdd(obj2.initReal(width));
+
+ if (dashLength > 0) {
+ Object obj3;
+
+ obj1->arrayAdd(obj3.initArray(xref));
+ for (int i = 0; i < dashLength; i++)
+ obj3.arrayAdd(obj2.initReal(dash[i]));
+ }
}
//------------------------------------------------------------------------
@@ -675,6 +682,38 @@ AnnotBorderBS::AnnotBorderBS(Dict *dict) {
}
}
+const char *AnnotBorderBS::getStyleName() const {
+ switch (style) {
+ case borderSolid:
+ return "S";
+ case borderDashed:
+ return "D";
+ case borderBeveled:
+ return "B";
+ case borderInset:
+ return "I";
+ case borderUnderlined:
+ return "U";
+ }
+
+ return "S";
+}
+
+void AnnotBorderBS::writeToObject(XRef *xref, Object *obj1) const {
+ Object obj2;
+
+ obj1->initDict(xref);
+ obj1->dictSet("W", obj2.initReal(width));
+ obj1->dictSet("S", obj2.initName(getStyleName()));
+ if (style == borderDashed && dashLength > 0) {
+ Object obj3;
+
+ obj1->dictSet("D", obj3.initArray(xref));
+ for (int i = 0; i < dashLength; i++)
+ obj3.arrayAdd(obj2.initReal(dash[i]));
+ }
+}
+
//------------------------------------------------------------------------
// AnnotColor
//------------------------------------------------------------------------
@@ -1441,14 +1480,14 @@ void Annot::setFlags(Guint new_flags) {
update ("F", &obj1);
}
-void Annot::setBorder(AnnotBorderArray *new_border) {
+void Annot::setBorder(AnnotBorder *new_border) {
annotLocker();
delete border;
if (new_border) {
Object obj1;
new_border->writeToObject(xref, &obj1);
- update ("Border", &obj1);
+ update(new_border->getType() == AnnotBorder::typeArray ? "Border" : "BS", &obj1);
border = new_border;
} else {
border = NULL;
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 0ff5042..8fde6a6 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -238,6 +238,8 @@ public:
virtual double *getDash() const { return dash; }
virtual AnnotBorderStyle getStyle() const { return style; }
+ virtual void writeToObject(XRef *xref, Object *obj1) const = 0;
+
protected:
AnnotBorder();
@@ -260,8 +262,6 @@ public:
AnnotBorderArray();
AnnotBorderArray(Array *array);
- void writeToObject(XRef *xref, Object *dest) const;
-
void setHorizontalCorner(double hc) { horizontalCorner = hc; }
void setVerticalCorner(double vc) { verticalCorner = vc; }
@@ -270,6 +270,7 @@ public:
private:
virtual AnnotBorderType getType() const { return typeArray; }
+ virtual void writeToObject(XRef *xref, Object *obj1) const;
double horizontalCorner; // (Default 0)
double verticalCorner; // (Default 0)
@@ -288,6 +289,9 @@ public:
private:
virtual AnnotBorderType getType() const { return typeBS; }
+ virtual void writeToObject(XRef *xref, Object *obj1) const;
+
+ const char *getStyleName() const;
// double width; // W (Default 1) (inherited from AnnotBorder)
// AnnotBorderStyle style; // S (Default S) (inherited from AnnotBorder)
@@ -580,7 +584,7 @@ public:
void setModified(GooString *new_date);
void setFlags(Guint new_flags);
- void setBorder(AnnotBorderArray *new_border); // Takes ownership
+ void setBorder(AnnotBorder *new_border); // Takes ownership
// The annotation takes the ownership of
// new_color.
commit 3979b82982e84107d93fbbe95350bf25ce47398d
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Tue Nov 26 14:44:57 2013 +0100
annots: Use a default border for annots that can have a BS entry
According to the spec if neither the Border nor the BS entry is present,
the border shall be drawn as a solid line with a width of 1 point.
However, acroread seems to ignore the Border entry for annots that can't
have a BS entry.
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 0661fd2..b94039f 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1292,18 +1292,14 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) {
}
//----- parse the border style
- if (dict->lookup("BS", &obj1)->isDict()) {
- border = new AnnotBorderBS(obj1.getDict());
- } else {
- obj1.free();
-
- if (dict->lookup("Border", &obj1)->isArray())
- border = new AnnotBorderArray(obj1.getArray());
- else
- // Adobe draws no border at all if the last element is of
- // the wrong type.
- border = NULL;
- }
+ // According to the spec if neither the Border nor the BS entry is present,
+ // the border shall be drawn as a solid line with a width of 1 point. But acroread
+ // seems to ignore the Border entry for annots that can't have a BS entry. So, we only
+ // follow this rule for annots tha can have a BS entry.
+ if (dict->lookup("Border", &obj1)->isArray())
+ border = new AnnotBorderArray(obj1.getArray());
+ else
+ border = NULL;
obj1.free();
if (dict->lookup("C", &obj1)->isArray()) {
@@ -2620,6 +2616,14 @@ void AnnotLink::initialize(PDFDoc *docA, Dict *dict) {
quadrilaterals = NULL;
}
obj1.free();
+
+ if (dict->lookup("BS", &obj1)->isDict()) {
+ delete border;
+ border = new AnnotBorderBS(obj1.getDict());
+ } else if (!border) {
+ border = new AnnotBorderBS();
+ }
+ obj1.free();
}
void AnnotLink::draw(Gfx *gfx, GBool printing) {
@@ -2747,6 +2751,14 @@ void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) {
}
obj1.free();
+ if (dict->lookup("BS", &obj1)->isDict()) {
+ delete border;
+ border = new AnnotBorderBS(obj1.getDict());
+ } else if (!border) {
+ border = new AnnotBorderBS();
+ }
+ obj1.free();
+
if (dict->lookup("BE", &obj1)->isDict()) {
borderEffect = new AnnotBorderEffect(obj1.getDict());
} else {
@@ -2946,7 +2958,7 @@ void AnnotFreeText::generateFreeTextAppearance()
appearBuf = new GooString ();
appearBuf->append ("q\n");
- borderWidth = border ? border->getWidth() : 0;
+ borderWidth = border->getWidth();
if (borderWidth > 0)
setLineStyleForBorder(border);
@@ -3234,6 +3246,14 @@ void AnnotLine::initialize(PDFDoc *docA, Dict *dict) {
captionTextHorizontal = captionTextVertical = 0;
}
obj1.free();
+
+ if (dict->lookup("BS", &obj1)->isDict()) {
+ delete border;
+ border = new AnnotBorderBS(obj1.getDict());
+ } else if (!border) {
+ border = new AnnotBorderBS();
+ }
+ obj1.free();
}
void AnnotLine::setContents(GooString *new_content) {
@@ -3332,7 +3352,7 @@ void AnnotLine::setIntent(AnnotLineIntent new_intent) {
void AnnotLine::generateLineAppearance()
{
- double borderWidth = 0, ca = opacity;
+ double borderWidth, ca = opacity;
appearBBox = new AnnotAppearanceBBox(rect);
appearBuf = new GooString ();
@@ -3341,10 +3361,8 @@ void AnnotLine::generateLineAppearance()
setColor(color, gFalse);
}
- if (border) {
- setLineStyleForBorder(border);
- borderWidth = border->getWidth();
- }
+ setLineStyleForBorder(border);
+ borderWidth = border->getWidth();
appearBBox->setBorderWidth(std::max(1., borderWidth));
const double x1 = coord1->getX();
@@ -3906,6 +3924,12 @@ void AnnotWidget::initialize(PDFDoc *docA, Dict *dict) {
}
obj1.free();
+ if (dict->lookup("BS", &obj1)->isDict()) {
+ delete border;
+ border = new AnnotBorderBS(obj1.getDict());
+ }
+ obj1.free();
+
updatedAppearanceStream.num = updatedAppearanceStream.gen = -1;
}
@@ -5426,6 +5450,14 @@ void AnnotGeometry::initialize(PDFDoc *docA, Dict* dict) {
}
obj1.free();
+ if (dict->lookup("BS", &obj1)->isDict()) {
+ delete border;
+ border = new AnnotBorderBS(obj1.getDict());
+ } else if (!border) {
+ border = new AnnotBorderBS();
+ }
+ obj1.free();
+
if (dict->lookup("BE", &obj1)->isDict()) {
borderEffect = new AnnotBorderEffect(obj1.getDict());
} else {
@@ -5490,73 +5522,70 @@ void AnnotGeometry::draw(Gfx *gfx, GBool printing) {
if (color)
setColor(color, gFalse);
- if (border) {
- double borderWidth = border->getWidth();
-
- setLineStyleForBorder(border);
+ double borderWidth = border->getWidth();
+ setLineStyleForBorder(border);
- if (interiorColor)
- setColor(interiorColor, gTrue);
+ if (interiorColor)
+ setColor(interiorColor, gTrue);
- if (type == typeSquare) {
- appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} re\n",
- borderWidth / 2.0, borderWidth / 2.0,
- (rect->x2 - rect->x1) - borderWidth,
- (rect->y2 - rect->y1) - borderWidth);
- } else {
- double width, height;
- double b;
- double x1, y1, x2, y2, x3, y3;
-
- width = rect->x2 - rect->x1;
- height = rect->y2 - rect->y1;
- b = borderWidth / 2.0;
-
- x1 = b;
- y1 = height / 2.0;
- appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x1, y1);
-
- y1 += height / 4.0;
- x2 = width / 4.0;
- y2 = height - b;
- x3 = width / 2.0;
- y3 = y2;
- appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n",
- x1, y1, x2, y2, x3, y3);
- x2 = width - b;
- y2 = y1;
- x1 = x3 + (width / 4.0);
- y1 = y3;
- x3 = x2;
- y3 = height / 2.0;
- appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n",
- x1, y1, x2, y2, x3, y3);
-
- x2 = x1;
- y2 = b;
- x1 = x3;
- y1 = height / 4.0;
- x3 = width / 2.0;
- y3 = b;
- appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n",
- x1, y1, x2, y2, x3, y3);
-
- x2 = b;
- y2 = y1;
- x1 = width / 4.0;
- y1 = b;
- x3 = b;
- y3 = height / 2.0;
- appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n",
- x1, y1, x2, y2, x3, y3);
+ if (type == typeSquare) {
+ appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} re\n",
+ borderWidth / 2.0, borderWidth / 2.0,
+ (rect->x2 - rect->x1) - borderWidth,
+ (rect->y2 - rect->y1) - borderWidth);
+ } else {
+ double width, height;
+ double b;
+ double x1, y1, x2, y2, x3, y3;
+
+ width = rect->x2 - rect->x1;
+ height = rect->y2 - rect->y1;
+ b = borderWidth / 2.0;
+
+ x1 = b;
+ y1 = height / 2.0;
+ appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x1, y1);
+
+ y1 += height / 4.0;
+ x2 = width / 4.0;
+ y2 = height - b;
+ x3 = width / 2.0;
+ y3 = y2;
+ appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n",
+ x1, y1, x2, y2, x3, y3);
+ x2 = width - b;
+ y2 = y1;
+ x1 = x3 + (width / 4.0);
+ y1 = y3;
+ x3 = x2;
+ y3 = height / 2.0;
+ appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n",
+ x1, y1, x2, y2, x3, y3);
+
+ x2 = x1;
+ y2 = b;
+ x1 = x3;
+ y1 = height / 4.0;
+ x3 = width / 2.0;
+ y3 = b;
+ appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n",
+ x1, y1, x2, y2, x3, y3);
+
+ x2 = b;
+ y2 = y1;
+ x1 = width / 4.0;
+ y1 = b;
+ x3 = b;
+ y3 = height / 2.0;
+ appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n",
+ x1, y1, x2, y2, x3, y3);
+ }
- }
+ if (interiorColor && interiorColor->getSpace() != AnnotColor::colorTransparent)
+ appearBuf->append ("b\n");
+ else
+ appearBuf->append ("S\n");
- if (interiorColor && interiorColor->getSpace() != AnnotColor::colorTransparent)
- appearBuf->append ("b\n");
- else
- appearBuf->append ("S\n");
- }
appearBuf->append ("Q\n");
double bbox[4];
@@ -5680,6 +5709,14 @@ void AnnotPolygon::initialize(PDFDoc *docA, Dict* dict) {
}
obj1.free();
+ if (dict->lookup("BS", &obj1)->isDict()) {
+ delete border;
+ border = new AnnotBorderBS(obj1.getDict());
+ } else if (!border) {
+ border = new AnnotBorderBS();
+ }
+ obj1.free();
+
if (dict->lookup("BE", &obj1)->isDict()) {
borderEffect = new AnnotBorderEffect(obj1.getDict());
} else {
@@ -5799,10 +5836,8 @@ void AnnotPolygon::draw(Gfx *gfx, GBool printing) {
setColor(color, gFalse);
}
- if (border) {
- setLineStyleForBorder(border);
- appearBBox->setBorderWidth(std::max(1., border->getWidth()));
- }
+ setLineStyleForBorder(border);
+ appearBBox->setBorderWidth(std::max(1., border->getWidth()));
if (interiorColor) {
setColor(interiorColor, gTrue);
@@ -5959,6 +5994,14 @@ void AnnotInk::initialize(PDFDoc *docA, Dict* dict) {
ok = gFalse;
}
obj1.free();
+
+ if (dict->lookup("BS", &obj1)->isDict()) {
+ delete border;
+ border = new AnnotBorderBS(obj1.getDict());
+ } else if (!border) {
+ border = new AnnotBorderBS();
+ }
+ obj1.free();
}
void AnnotInk::writeInkList(AnnotPath **paths, int n_paths, Array *dest_array) {
@@ -6026,10 +6069,8 @@ void AnnotInk::draw(Gfx *gfx, GBool printing) {
setColor(color, gFalse);
}
- if (border) {
- setLineStyleForBorder(border);
- appearBBox->setBorderWidth(std::max(1., border->getWidth()));
- }
+ setLineStyleForBorder(border);
+ appearBBox->setBorderWidth(std::max(1., border->getWidth()));
for (int i = 0; i < inkListLength; ++i) {
const AnnotPath * path = inkList[i];
@@ -6290,7 +6331,7 @@ void AnnotFileAttachment::draw(Gfx *gfx, GBool printing) {
// draw the appearance stream
appearance.fetch(gfx->getXRef(), &obj);
- gfx->drawAnnot(&obj, border, color,
+ gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
rect->x1, rect->y1, rect->x2, rect->y2, getRotation());
obj.free();
}
@@ -6452,7 +6493,7 @@ void AnnotSound::draw(Gfx *gfx, GBool printing) {
// draw the appearance stream
appearance.fetch(gfx->getXRef(), &obj);
- gfx->drawAnnot(&obj, border, color,
+ gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
rect->x1, rect->y1, rect->x2, rect->y2, getRotation());
obj.free();
}
commit 36c07c82bdff010695c5d615b67506922522d0e8
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Tue Nov 26 14:07:21 2013 +0100
annots: Add helper function Annot::setLineStyleForBorder
It sets the line dash and width based on the given AnnotBorder. Use it
only when the border width is greater than 0 for FreeText annotations
and always for annotations that use the border to set the line width and
dash, but don't draw a border.
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 021a49d..0661fd2 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1660,6 +1660,26 @@ void Annot::setColor(AnnotColor *color, GBool fill) {
}
}
+void Annot::setLineStyleForBorder(AnnotBorder *border) {
+ int i, dashLength;
+ double *dash;
+
+ switch (border->getStyle()) {
+ case AnnotBorder::borderDashed:
+ appearBuf->append("[");
+ dashLength = border->getDashLength();
+ dash = border->getDash();
+ for (i = 0; i < dashLength; ++i)
+ appearBuf->appendf(" {0:.2f}", dash[i]);
+ appearBuf->append(" ] 0 d\n");
+ break;
+ default:
+ appearBuf->append("[] 0 d\n");
+ break;
+ }
+ appearBuf->appendf("{0:.2f} w\n", border->getWidth());
+}
+
// Draw an (approximate) circle of radius <r> centered at (<cx>, <cy>).
// If <fill> is true, the circle is filled; otherwise it is stroked.
void Annot::drawCircle(double cx, double cy, double r, GBool fill) {
@@ -2925,29 +2945,10 @@ void AnnotFreeText::generateFreeTextAppearance()
appearBuf = new GooString ();
appearBuf->append ("q\n");
-
- if (border) {
- int i, dashLength;
- double *dash;
- borderWidth = border->getWidth();
- switch (border->getStyle()) {
- case AnnotBorder::borderDashed:
- appearBuf->append("[");
- dashLength = border->getDashLength();
- dash = border->getDash();
- for (i = 0; i < dashLength; ++i)
- appearBuf->appendf(" {0:.2f}", dash[i]);
- appearBuf->append(" ] 0 d\n");
- break;
- default:
- appearBuf->append("[] 0 d\n");
- break;
- }
- appearBuf->appendf("{0:.2f} w\n", borderWidth);
- } else {
- borderWidth = 0; // No border
- }
+ borderWidth = border ? border->getWidth() : 0;
+ if (borderWidth > 0)
+ setLineStyleForBorder(border);
// Box size
const double width = rect->x2 - rect->x1;
@@ -3331,7 +3332,7 @@ void AnnotLine::setIntent(AnnotLineIntent new_intent) {
void AnnotLine::generateLineAppearance()
{
- double borderWidth, ca = opacity;
+ double borderWidth = 0, ca = opacity;
appearBBox = new AnnotAppearanceBBox(rect);
appearBuf = new GooString ();
@@ -3341,28 +3342,10 @@ void AnnotLine::generateLineAppearance()
}
if (border) {
- int i, dashLength;
- double *dash;
-
- switch (border->getStyle()) {
- case AnnotBorder::borderDashed:
- appearBuf->append("[");
- dashLength = border->getDashLength();
- dash = border->getDash();
- for (i = 0; i < dashLength; ++i)
- appearBuf->appendf(" {0:.2f}", dash[i]);
- appearBuf->append(" ] 0 d\n");
- break;
- default:
- appearBuf->append("[] 0 d\n");
- break;
- }
+ setLineStyleForBorder(border);
borderWidth = border->getWidth();
- appearBuf->appendf("{0:.2f} w\n", borderWidth);
- appearBBox->setBorderWidth(borderWidth);
- } else {
- borderWidth = 0;
}
+ appearBBox->setBorderWidth(std::max(1., borderWidth));
const double x1 = coord1->getX();
const double y1 = coord1->getY();
@@ -5508,24 +5491,9 @@ void AnnotGeometry::draw(Gfx *gfx, GBool printing) {
setColor(color, gFalse);
if (border) {
- int i, dashLength;
- double *dash;
double borderWidth = border->getWidth();
- switch (border->getStyle()) {
- case AnnotBorder::borderDashed:
- appearBuf->append("[");
- dashLength = border->getDashLength();
- dash = border->getDash();
- for (i = 0; i < dashLength; ++i)
- appearBuf->appendf(" {0:.2f}", dash[i]);
- appearBuf->append(" ] 0 d\n");
- break;
- default:
- appearBuf->append("[] 0 d\n");
- break;
- }
- appearBuf->appendf("{0:.2f} w\n", borderWidth);
+ setLineStyleForBorder(border);
if (interiorColor)
setColor(interiorColor, gTrue);
@@ -5832,24 +5800,8 @@ void AnnotPolygon::draw(Gfx *gfx, GBool printing) {
}
if (border) {
- int i, dashLength;
- double *dash;
-
- switch (border->getStyle()) {
- case AnnotBorder::borderDashed:
- appearBuf->append("[");
- dashLength = border->getDashLength();
- dash = border->getDash();
- for (i = 0; i < dashLength; ++i)
- appearBuf->appendf(" {0:.2f}", dash[i]);
- appearBuf->append(" ] 0 d\n");
- break;
- default:
- appearBuf->append("[] 0 d\n");
- break;
- }
- appearBuf->appendf("{0:.2f} w\n", border->getWidth());
- appearBBox->setBorderWidth(border->getWidth());
+ setLineStyleForBorder(border);
+ appearBBox->setBorderWidth(std::max(1., border->getWidth()));
}
if (interiorColor) {
@@ -6075,8 +6027,8 @@ void AnnotInk::draw(Gfx *gfx, GBool printing) {
}
if (border) {
- appearBuf->appendf("{0:.2f} w\n", border->getWidth());
- appearBBox->setBorderWidth(border->getWidth());
+ setLineStyleForBorder(border);
+ appearBBox->setBorderWidth(std::max(1., border->getWidth()));
}
for (int i = 0; i < inkListLength; ++i) {
diff --git a/poppler/Annot.h b/poppler/Annot.h
index e5eac45..0ff5042 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -624,6 +624,7 @@ protected:
virtual ~Annot();
virtual void removeReferencedObjects(); // Called by Page::removeAnnot
void setColor(AnnotColor *color, GBool fill);
+ void setLineStyleForBorder(AnnotBorder *border);
void drawCircle(double cx, double cy, double r, GBool fill);
void drawCircleTopLeft(double cx, double cy, double r);
void drawCircleBottomRight(double cx, double cy, double r);
commit e7b1ff97318fd6c3a8fed3a33d45f1cb55208b28
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Tue Nov 26 11:40:57 2013 +0100
annots: Remove unused typeUnknown AnnotBorderType from AnnotBorder
Also make the AnnotBorder constructor protected to make sure it's not
possible to create AnnotBorder instances.
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 5b83db2..021a49d 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -520,7 +520,6 @@ AnnotQuadrilaterals::AnnotQuadrilateral::AnnotQuadrilateral(double x1, double y1
// AnnotBorder
//------------------------------------------------------------------------
AnnotBorder::AnnotBorder() {
- type = typeUnknown;
width = 1;
dashLength = 0;
dash = NULL;
@@ -565,7 +564,6 @@ AnnotBorder::~AnnotBorder() {
//------------------------------------------------------------------------
AnnotBorderArray::AnnotBorderArray() {
- type = typeArray;
horizontalCorner = 0;
verticalCorner = 0;
}
@@ -627,7 +625,6 @@ void AnnotBorderArray::writeToObject(XRef *xref, Object *obj1) const {
//------------------------------------------------------------------------
AnnotBorderBS::AnnotBorderBS() {
- type = typeBS;
}
AnnotBorderBS::AnnotBorderBS(Dict *dict) {
diff --git a/poppler/Annot.h b/poppler/Annot.h
index bd3ff80..e5eac45 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -216,7 +216,6 @@ protected:
class AnnotBorder {
public:
enum AnnotBorderType {
- typeUnknown,
typeArray,
typeBS
};
@@ -229,18 +228,19 @@ public:
borderUnderlined // Underlined
};
- AnnotBorder();
virtual ~AnnotBorder();
virtual void setWidth(double new_width) { width = new_width; }
- virtual AnnotBorderType getType() const { return type; }
+ virtual AnnotBorderType getType() const = 0;
virtual double getWidth() const { return width; }
virtual int getDashLength() const { return dashLength; }
virtual double *getDash() const { return dash; }
virtual AnnotBorderStyle getStyle() const { return style; }
protected:
+ AnnotBorder();
+
GBool parseDashArray(Object *dashObj);
AnnotBorderType type;
@@ -268,7 +268,9 @@ public:
double getHorizontalCorner() const { return horizontalCorner; }
double getVerticalCorner() const { return verticalCorner; }
-protected:
+private:
+ virtual AnnotBorderType getType() const { return typeArray; }
+
double horizontalCorner; // (Default 0)
double verticalCorner; // (Default 0)
// double width; // (Default 1) (inherited from AnnotBorder)
@@ -285,6 +287,8 @@ public:
AnnotBorderBS(Dict *dict);
private:
+ virtual AnnotBorderType getType() const { return typeBS; }
+
// double width; // W (Default 1) (inherited from AnnotBorder)
// AnnotBorderStyle style; // S (Default S) (inherited from AnnotBorder)
// double *dash; // D (Default [3]) (inherited from AnnotBorder)
More information about the poppler
mailing list