[poppler] poppler/Annot.cc poppler/Page.cc
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Sat Apr 18 02:46:18 PDT 2015
poppler/Annot.cc | 19 +++++++++++++++++++
poppler/Page.cc | 11 ++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
New commits:
commit 05ef3f9feee760544108c68e0d45d1de25fd8901
Author: Philipp Reinkemeier <philipp.reinkemeier at offis.de>
Date: Mon Feb 16 09:11:58 2015 +0100
annots: Fixed adding annotation of Subtype Popup to pdf page
https://bugs.freedesktop.org/show_bug.cgi?id=89136
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index d7769a0..598d148 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -2089,6 +2089,16 @@ void AnnotMarkup::setLabel(GooString *new_label) {
}
void AnnotMarkup::setPopup(AnnotPopup *new_popup) {
+ // If there exists an old popup annotation that is already
+ // associated with a page, then we need to remove that
+ // popup annotation from the page. Otherwise we would have
+ // dangling references to it.
+ if (popup != NULL && popup->getPageNum() != 0) {
+ Page *pageobj = doc->getPage(popup->getPageNum());
+ if (pageobj) {
+ pageobj->removeAnnot(popup);
+ }
+ }
delete popup;
if (new_popup) {
@@ -2100,6 +2110,15 @@ void AnnotMarkup::setPopup(AnnotPopup *new_popup) {
new_popup->setParent(this);
popup = new_popup;
+
+ // If this annotation is already added to a page, then we
+ // add the new popup annotation to the same page.
+ if (page != 0) {
+ Page *pageobj = doc->getPage(page);
+ assert(pageobj != NULL); // pageobj should exist in doc (see setPage())
+
+ pageobj->addAnnot(popup);
+ }
} else {
popup = NULL;
}
diff --git a/poppler/Page.cc b/poppler/Page.cc
index 98c13c1..ef0811b 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -442,8 +442,17 @@ void Page::addAnnot(Annot *annot) {
obj1.free();
}
- annots->appendAnnot(annot);
+ if (annot->getType() != Annot::typePopup) {
+ annots->appendAnnot(annot);
+ }
annot->setPage(num, gTrue);
+
+ AnnotMarkup *annotMarkup = dynamic_cast<AnnotMarkup*>(annot);
+ if (annotMarkup) {
+ AnnotPopup *annotPopup = annotMarkup->getPopup();
+ if (annotPopup)
+ addAnnot(annotPopup);
+ }
}
void Page::removeAnnot(Annot *annot) {
More information about the poppler
mailing list