Commit 13ac2c0b authored by Fabio D'Urso's avatar Fabio D'Urso Committed by Albert Astals Cid

Added some new setters to Annot and AnnotMarkup

parent aa2b5ffa
......@@ -24,6 +24,7 @@
// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
// Copyright (C) 2009 Ilya Gorenbein <igorenbein@finjan.com>
// Copyright (C) 2011 José Aliste <jaliste@src.gnome.org>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -1020,18 +1021,52 @@ void Annot::getRect(double *x1, double *y1, double *x2, double *y2) const {
*y2 = rect->y2;
}
void Annot::setRect(PDFRectangle *rect) {
setRect(rect->x1, rect->y1, rect->x2, rect->y2);
}
void Annot::setRect(double x1, double y1, double x2, double y2) {
Object obj1, obj2;
if (x1 < x2) {
rect->x1 = x1;
rect->x2 = x2;
} else {
rect->x1 = x2;
rect->x2 = x1;
}
if (y1 < y2) {
rect->y1 = y1;
rect->y2 = y2;
} else {
rect->y1 = y2;
rect->y2 = y1;
}
obj1.initArray (xref);
obj1.arrayAdd (obj2.initReal (rect->x1));
obj1.arrayAdd (obj2.initReal (rect->y1));
obj1.arrayAdd (obj2.initReal (rect->x2));
obj1.arrayAdd (obj2.initReal (rect->y2));
update("Rect", &obj1);
}
GBool Annot::inRect(double x, double y) const {
return rect->contains(x, y);
}
void Annot::update(const char *key, Object *value) {
/* Set M to current time */
delete modified;
modified = timeToDateString(NULL);
/* Set M to current time, unless we are updating M itself */
if (strcmp(key, "M") != 0) {
delete modified;
modified = timeToDateString(NULL);
Object obj1;
obj1.initString (modified->copy());
annotObj.dictSet("M", &obj1);
Object obj1;
obj1.initString (modified->copy());
annotObj.dictSet("M", &obj1);
}
annotObj.dictSet(const_cast<char*>(key), value);
......@@ -1057,6 +1092,40 @@ void Annot::setContents(GooString *new_content) {
update ("Contents", &obj1);
}
void Annot::setName(GooString *new_name) {
delete name;
if (new_name) {
name = new GooString(new_name);
} else {
name = new GooString();
}
Object obj1;
obj1.initString(name->copy());
update ("NM", &obj1);
}
void Annot::setModified(GooString *new_modified) {
delete modified;
if (new_modified)
modified = new GooString(new_modified);
else
modified = new GooString();
Object obj1;
obj1.initString(modified->copy());
update ("M", &obj1);
}
void Annot::setFlags(Guint new_flags) {
Object obj1;
flags = new_flags;
obj1.initInt(flags);
update ("F", &obj1);
}
void Annot::setColor(AnnotColor *new_color) {
delete color;
......@@ -1554,6 +1623,19 @@ void AnnotMarkup::setOpacity(double opacityA) {
update ("CA", &obj1);
}
void AnnotMarkup::setDate(GooString *new_date) {
delete date;
if (new_date)
date = new GooString(new_date);
else
date = new GooString();
Object obj1;
obj1.initString(date->copy());
update ("CreationDate", &obj1);
}
//------------------------------------------------------------------------
// AnnotText
//------------------------------------------------------------------------
......
......@@ -22,6 +22,7 @@
// Copyright (C) 2008 Pino Toscano <pino@kde.org>
// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
// Copyright (C) 2009-2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -474,9 +475,15 @@ public:
double getFontSize() { return fontSize; }
void setRect(PDFRectangle *rect);
void setRect(double x1, double y1, double x2, double y2);
// Sets the annot contents to new_content
// new_content should never be NULL
void setContents(GooString *new_content);
void setName(GooString *new_name);
void setModified(GooString *new_date);
void setFlags(Guint new_flags);
// The annotation takes the ownership of
// new_color.
......@@ -620,6 +627,7 @@ public:
void setPopup(AnnotPopup *new_popup);
void setLabel(GooString *new_label);
void setOpacity(double opacityA);
void setDate(GooString *new_date);
protected:
GooString *label; // T (Default autor)
......
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