[poppler] 4 commits - poppler/Annot.cc poppler/Annot.h poppler/PDFDoc.cc poppler/XRef.cc poppler/XRef.h
Albert Astals Cid
aacid at kemper.freedesktop.org
Thu Mar 22 16:46:33 PDT 2012
poppler/Annot.cc | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++---
poppler/Annot.h | 11 ++++++++
poppler/PDFDoc.cc | 15 +++++++---
poppler/XRef.cc | 15 ++++++++++
poppler/XRef.h | 2 +
5 files changed, 109 insertions(+), 8 deletions(-)
New commits:
commit 06b6db92dd1ec32f9a55347073f8b533aa074ee1
Author: Fabio D'Urso <fabiodurso at hotmail.it>
Date: Sun Mar 18 23:58:05 2012 +0100
Added XRef::removeIndirectObject
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index ecc5980..898bcbb 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -27,6 +27,7 @@
// Copyright (C) 2010 Srinivas Adicherla <srinivas.adicherla at geodesic.com>
// Copyright (C) 2010 Philip Lorenz <lorenzph+freedesktop at gmail.com>
// Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2012 Fabio D'Urso <fabiodurso at 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
@@ -841,14 +842,18 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr)
continue;
if (xref->getEntry(i)->updated) { //we have an updated object
- Object obj1;
Ref ref;
ref.num = i;
ref.gen = xref->getEntry(i)->type == xrefEntryCompressed ? 0 : xref->getEntry(i)->gen;
- xref->fetch(ref.num, ref.gen, &obj1);
- Guint offset = writeObject(&obj1, &ref, outStr);
- uxref->add(ref.num, ref.gen, offset, gTrue);
- obj1.free();
+ if (xref->getEntry(i)->type != xrefEntryFree) {
+ Object obj1;
+ xref->fetch(ref.num, ref.gen, &obj1);
+ Guint offset = writeObject(&obj1, &ref, outStr);
+ uxref->add(ref.num, ref.gen, offset, gTrue);
+ obj1.free();
+ } else {
+ uxref->add(ref.num, ref.gen, 0, gFalse);
+ }
}
}
if (uxref->getNumObjects() == 0) { //we have nothing to update
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 699eb6b..60c2f9d 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -21,6 +21,7 @@
// Copyright (C) 2009, 2010 Ilya Gorenbein <igorenbein at finjan.com>
// Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag at kabelmail.de>
+// Copyright (C) 2012 Fabio D'Urso <fabiodurso at 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
@@ -1222,6 +1223,20 @@ Ref XRef::addIndirectObject (Object* o) {
return r;
}
+void XRef::removeIndirectObject(Ref r) {
+ if (r.num < 0 || r.num >= size) {
+ error(errInternal, -1,"XRef::removeIndirectObject on unknown ref: {0:d}, {1:d}\n", r.num, r.gen);
+ return;
+ }
+ XRefEntry *e = getEntry(r.num);
+ if (e->type == xrefEntryFree)
+ return;
+ e->obj.free();
+ e->type = xrefEntryFree;
+ e->gen++;
+ e->updated = true;
+}
+
void XRef::writeToFile(OutStream* outStr, GBool writeAllEntries) {
//create free entries linked-list
if (getEntry(0)->gen != 65535) {
diff --git a/poppler/XRef.h b/poppler/XRef.h
index c7b20bd..ea2c1b4 100644
--- a/poppler/XRef.h
+++ b/poppler/XRef.h
@@ -20,6 +20,7 @@
// Copyright (C) 2010 Ilya Gorenbein <igorenbein at finjan.com>
// Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag at kabelmail.de>
+// Copyright (C) 2012 Fabio D'Urso <fabiodurso at 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
@@ -132,6 +133,7 @@ public:
// Write access
void setModifiedObject(Object* o, Ref r);
Ref addIndirectObject (Object* o);
+ void removeIndirectObject(Ref r);
void add(int num, int gen, Guint offs, GBool used);
void writeToFile(OutStream* outStr, GBool writeAllEntries);
commit a2e9b7c02ffa0e5edc4da18cc726993bc92fc684
Author: Fabio D'Urso <fabiodurso at hotmail.it>
Date: Mon Mar 19 19:17:09 2012 +0100
Fix in AnnotMarkup's popup window handling
AnnotPopup's ref was previously set to the *parent* annot, now it's correctly
set to the *popup* annot's own.
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 9b1c710..405f5f6 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1573,7 +1573,7 @@ AnnotMarkup::~AnnotMarkup() {
}
void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict, Object *obj) {
- Object obj1;
+ Object obj1, obj2;
if (dict->lookup("T", &obj1)->isString()) {
label = obj1.getString()->copy();
@@ -1582,8 +1582,8 @@ void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict, Object *obj) {
}
obj1.free();
- if (dict->lookup("Popup", &obj1)->isDict()) {
- popup = new AnnotPopup(docA, obj1.getDict(), obj);
+ if (dict->lookup("Popup", &obj1)->isDict() && dict->lookupNF("Popup", &obj2)->isRef()) {
+ popup = new AnnotPopup(docA, obj1.getDict(), &obj2);
} else {
popup = NULL;
}
commit 05641304df67beae546a2fe18071f3be52707aa8
Author: Fabio D'Urso <fabiodurso at hotmail.it>
Date: Mon Mar 19 20:56:45 2012 +0100
Basic Annot border editing support
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 208c43d..9b1c710 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -557,6 +557,16 @@ AnnotBorderArray::AnnotBorderArray(Array *array) {
}
}
+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
+}
+
//------------------------------------------------------------------------
// AnnotBorderBS
//------------------------------------------------------------------------
@@ -1169,6 +1179,19 @@ void Annot::setFlags(Guint new_flags) {
update ("F", &obj1);
}
+void Annot::setBorder(AnnotBorderArray *new_border) {
+ delete border;
+
+ if (new_border) {
+ Object obj1;
+ new_border->writeToObject(xref, &obj1);
+ update ("Border", &obj1);
+ border = new_border;
+ } else {
+ border = NULL;
+ }
+}
+
void Annot::setColor(AnnotColor *new_color) {
delete color;
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 611974c..8d40a8a 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -228,6 +228,8 @@ public:
AnnotBorder();
virtual ~AnnotBorder();
+ virtual void setWidth(double new_width) { width = new_width; }
+
virtual AnnotBorderType getType() const { return type; }
virtual double getWidth() const { return width; }
virtual int getDashLength() const { return dashLength; }
@@ -254,6 +256,11 @@ public:
AnnotBorderArray();
AnnotBorderArray(Array *array);
+ void writeToObject(XRef *xref, Object *dest) const;
+
+ void setHorizontalCorner(double hc) { horizontalCorner = hc; }
+ void setVerticalCorner(double vc) { verticalCorner = vc; }
+
double getHorizontalCorner() const { return horizontalCorner; }
double getVerticalCorner() const { return verticalCorner; }
@@ -487,6 +494,8 @@ public:
void setModified(GooString *new_date);
void setFlags(Guint new_flags);
+ void setBorder(AnnotBorderArray *new_border); // Takes ownership
+
// The annotation takes the ownership of
// new_color.
void setColor(AnnotColor *new_color);
commit 3e6275a05066c152b265cc27275d9e4107c089e9
Author: Fabio D'Urso <fabiodurso at hotmail.it>
Date: Fri Mar 16 21:47:02 2012 +0100
Yet new setters to AnnotFreeText
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index f6eacbb..208c43d 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -2346,6 +2346,20 @@ void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) {
obj1.free();
}
+void AnnotFreeText::setAppearanceString(GooString *new_string) {
+ delete appearanceString;
+
+ if (new_string) {
+ appearanceString = new GooString(new_string);
+ } else {
+ appearanceString = new GooString();
+ }
+
+ Object obj1;
+ obj1.initString(appearanceString->copy());
+ update ("DA", &obj1);
+}
+
void AnnotFreeText::setQuadding(AnnotFreeTextQuadding new_quadding) {
Object obj1;
quadding = new_quadding;
@@ -2372,6 +2386,37 @@ void AnnotFreeText::setStyleString(GooString *new_string) {
update ("DS", &obj1);
}
+void AnnotFreeText::setCalloutLine(AnnotCalloutLine *line) {
+ delete calloutLine;
+
+ Object obj1;
+ if (line == NULL) {
+ obj1.initNull();
+ calloutLine = NULL;
+ } else {
+ double x1 = line->getX1(), y1 = line->getY1();
+ double x2 = line->getX2(), y2 = line->getY2();
+ Object obj2;
+ obj1.initArray(xref);
+ obj1.arrayAdd( obj2.initReal(x1) );
+ obj1.arrayAdd( obj2.initReal(y1) );
+ obj1.arrayAdd( obj2.initReal(x2) );
+ obj1.arrayAdd( obj2.initReal(y2) );
+
+ AnnotCalloutMultiLine *mline = dynamic_cast<AnnotCalloutMultiLine*>(line);
+ if (mline) {
+ double x3 = mline->getX3(), y3 = mline->getY3();
+ obj1.arrayAdd( obj2.initReal(x3) );
+ obj1.arrayAdd( obj2.initReal(y3) );
+ calloutLine = new AnnotCalloutMultiLine(x1, y1, x2, y2, x3, y3);
+ } else {
+ calloutLine = new AnnotCalloutLine(x1, y1, x2, y2);
+ }
+ }
+
+ update("CL", &obj1);
+}
+
void AnnotFreeText::setIntent(AnnotFreeTextIntent new_intent) {
Object obj1;
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 5a2a7bc..611974c 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -807,8 +807,10 @@ public:
AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj);
~AnnotFreeText();
+ void setAppearanceString(GooString *new_string);
void setQuadding(AnnotFreeTextQuadding new_quadding);
void setStyleString(GooString *new_string);
+ void setCalloutLine(AnnotCalloutLine *line);
void setIntent(AnnotFreeTextIntent new_intent);
// getters
More information about the poppler
mailing list