Commit e109cf24 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos
Browse files

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.
parent 3979b829
......@@ -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;
......
......@@ -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.
......
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