[poppler] 4 commits - poppler/Annot.cc poppler/Annot.h qt4/src qt5/src

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Mon Jul 1 05:48:06 PDT 2013


 poppler/Annot.cc              |   57 ++++++++++++++++++++++++++++++++++++++----
 poppler/Annot.h               |   10 ++++---
 qt4/src/poppler-annotation.cc |   34 -------------------------
 qt5/src/poppler-annotation.cc |   34 -------------------------
 4 files changed, 58 insertions(+), 77 deletions(-)

New commits:
commit c376559bc412e90204162bb4b2d20cd586db70c1
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Jun 30 13:14:07 2013 +0200

    annots: Invalidate the appearance stream when annot properties change
    
    Make invalidateAppearance() protected and only call it when properties
    that affect the appearance stream are updated. Remove all calls to
    invalidateAppearance() from qt frontend, this is now handled by the core
    and fixes the appearance stream regeneration in the glib frontend too.

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 420340f..454ce71 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1344,6 +1344,7 @@ void Annot::setRect(double x1, double y1, double x2, double y2) {
   obj1.arrayAdd (obj2.initReal (rect->y2));
 
   update("Rect", &obj1);
+  invalidateAppearance();
 }
 
 GBool Annot::inRect(double x, double y) const {
@@ -1436,6 +1437,7 @@ void Annot::setBorder(AnnotBorderArray *new_border) {
   } else {
     border = NULL;
   }
+  invalidateAppearance();
 }
 
 void Annot::setColor(AnnotColor *new_color) {
@@ -1450,6 +1452,7 @@ void Annot::setColor(AnnotColor *new_color) {
   } else {
     color = NULL;
   }
+  invalidateAppearance();
 }
 
 void Annot::setPage(int pageIndex, GBool updateP) {
@@ -2021,6 +2024,7 @@ void AnnotMarkup::setOpacity(double opacityA) {
   opacity = opacityA;
   obj1.initReal(opacity);
   update ("CA", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotMarkup::setDate(GooString *new_date) {
@@ -2179,6 +2183,7 @@ void AnnotText::setIcon(GooString *new_icon) {
   Object obj1;
   obj1.initName (icon->getCString());
   update("Name", &obj1);
+  invalidateAppearance();
 }
 
 #define ANNOT_TEXT_AP_NOTE                                                    \
@@ -2725,6 +2730,11 @@ void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) {
   obj1.free();
 }
 
+void AnnotFreeText::setContents(GooString *new_content) {
+  Annot::setContents(new_content);
+  invalidateAppearance();
+}
+
 void AnnotFreeText::setAppearanceString(GooString *new_string) {
   delete appearanceString;
 
@@ -2737,6 +2747,7 @@ void AnnotFreeText::setAppearanceString(GooString *new_string) {
   Object obj1;
   obj1.initString(appearanceString->copy());
   update ("DA", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotFreeText::setQuadding(AnnotFreeTextQuadding new_quadding) {
@@ -2744,6 +2755,7 @@ void AnnotFreeText::setQuadding(AnnotFreeTextQuadding new_quadding) {
   quadding = new_quadding;
   obj1.initInt((int)quadding);
   update ("Q", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotFreeText::setStyleString(GooString *new_string) {
@@ -2794,6 +2806,7 @@ void AnnotFreeText::setCalloutLine(AnnotCalloutLine *line) {
   }
 
   update("CL", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotFreeText::setIntent(AnnotFreeTextIntent new_intent) {
@@ -3202,6 +3215,12 @@ void AnnotLine::initialize(PDFDoc *docA, Dict *dict) {
   obj1.free();
 }
 
+void AnnotLine::setContents(GooString *new_content) {
+  Annot::setContents(new_content);
+  if (caption)
+    invalidateAppearance();
+}
+
 void AnnotLine::setVertices(double x1, double y1, double x2, double y2) {
   Object obj1, obj2;
 
@@ -3217,6 +3236,7 @@ void AnnotLine::setVertices(double x1, double y1, double x2, double y2) {
   obj1.arrayAdd( obj2.initReal(y2) );
 
   update("L", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotLine::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end) {
@@ -3230,6 +3250,7 @@ void AnnotLine::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyl
   obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( endStyle )) );
 
   update("LE", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotLine::setInteriorColor(AnnotColor *new_color) {
@@ -3243,6 +3264,7 @@ void AnnotLine::setInteriorColor(AnnotColor *new_color) {
   } else {
     interiorColor = NULL;
   }
+  invalidateAppearance();
 }
 
 void AnnotLine::setLeaderLineLength(double len) {
@@ -3251,6 +3273,7 @@ void AnnotLine::setLeaderLineLength(double len) {
   leaderLineLength = len;
   obj1.initReal(len);
   update ("LL", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotLine::setLeaderLineExtension(double len) {
@@ -3263,6 +3286,7 @@ void AnnotLine::setLeaderLineExtension(double len) {
   // LL is required if LLE is present
   obj1.initReal(leaderLineLength);
   update ("LL", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotLine::setCaption(bool new_cap) {
@@ -3271,6 +3295,7 @@ void AnnotLine::setCaption(bool new_cap) {
   caption = new_cap;
   obj1.initBool(new_cap);
   update ("Cap", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotLine::setIntent(AnnotLineIntent new_intent) {
@@ -3603,6 +3628,7 @@ void AnnotTextMarkup::setType(AnnotSubtype new_type) {
 
   type = new_type;
   update("Subtype", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotTextMarkup::setQuadrilaterals(AnnotQuadrilaterals *quadPoints) {
@@ -3623,6 +3649,7 @@ void AnnotTextMarkup::setQuadrilaterals(AnnotQuadrilaterals *quadPoints) {
   quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect);
 
   annotObj.dictSet ("QuadPoints", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) {
@@ -5334,6 +5361,7 @@ void AnnotStamp::setIcon(GooString *new_icon) {
   Object obj1;
   obj1.initName (icon->getCString());
   update("Name", &obj1);
+  invalidateAppearance();
 }
 
 //------------------------------------------------------------------------
@@ -5421,6 +5449,7 @@ void AnnotGeometry::setType(AnnotSubtype new_type) {
 
   type = new_type;
   update("Subtype", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotGeometry::setInteriorColor(AnnotColor *new_color) {
@@ -5434,6 +5463,7 @@ void AnnotGeometry::setInteriorColor(AnnotColor *new_color) {
   } else {
     interiorColor = NULL;
   }
+  invalidateAppearance();
 }
 
 void AnnotGeometry::draw(Gfx *gfx, GBool printing) {
@@ -5696,6 +5726,7 @@ void AnnotPolygon::setType(AnnotSubtype new_type) {
 
   type = new_type;
   update("Subtype", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotPolygon::setVertices(AnnotPath *path) {
@@ -5712,6 +5743,7 @@ void AnnotPolygon::setVertices(AnnotPath *path) {
   vertices = new AnnotPath(obj1.getArray());
 
   update("Vertices", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotPolygon::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end) {
@@ -5725,6 +5757,7 @@ void AnnotPolygon::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingS
   obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( endStyle )) );
 
   update("LE", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotPolygon::setInteriorColor(AnnotColor *new_color) {
@@ -5738,6 +5771,7 @@ void AnnotPolygon::setInteriorColor(AnnotColor *new_color) {
   } else {
     interiorColor = NULL;
   }
+  invalidateAppearance();
 }
 
 void AnnotPolygon::setIntent(AnnotPolygonIntent new_intent) {
@@ -5901,6 +5935,7 @@ void AnnotCaret::setSymbol(AnnotCaretSymbol new_symbol) {
   obj1.initName( new_symbol == symbolP ? "P" : "None" );
   symbol = new_symbol;
   update("Sy", &obj1);
+  invalidateAppearance();
 }
 
 //------------------------------------------------------------------------
@@ -5992,6 +6027,7 @@ void AnnotInk::setInkList(AnnotPath **paths, int n_paths) {
 
   parseInkList(obj1.getArray());
   annotObj.dictSet ("InkList", &obj1);
+  invalidateAppearance();
 }
 
 void AnnotInk::draw(Gfx *gfx, GBool printing) {
diff --git a/poppler/Annot.h b/poppler/Annot.h
index af29eb2..90c7328 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -563,7 +563,7 @@ public:
 
   // Sets the annot contents to new_content
   // new_content should never be NULL
-  void setContents(GooString *new_content);
+  virtual void setContents(GooString *new_content);
   void setName(GooString *new_name);
   void setModified(GooString *new_date);
   void setFlags(Guint new_flags);
@@ -576,9 +576,6 @@ public:
 
   void setAppearanceState(const char *state);
 
-  // Delete appearance streams and reset appearance state
-  void invalidateAppearance();
-
   // getters
   PDFDoc *getDoc() const { return doc; }
   XRef *getXRef() const { return xref; }
@@ -632,6 +629,9 @@ protected:
   // and sets M to the current time
   void update(const char *key, Object *value);
 
+  // Delete appearance streams and reset appearance state
+  void invalidateAppearance();
+
   int refCnt;
 
   Object annotObj;
@@ -905,6 +905,7 @@ public:
 
   virtual void draw(Gfx *gfx, GBool printing);
   virtual Object *getAppearanceResDict(Object *dest);
+  virtual void setContents(GooString *new_content);
 
   void setAppearanceString(GooString *new_string);
   void setQuadding(AnnotFreeTextQuadding new_quadding);
@@ -968,6 +969,7 @@ public:
 
   virtual void draw(Gfx *gfx, GBool printing);
   virtual Object *getAppearanceResDict(Object *dest);
+  virtual void setContents(GooString *new_content);
 
   void setVertices(double x1, double y1, double x2, double y2);
   void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end);
diff --git a/qt4/src/poppler-annotation.cc b/qt4/src/poppler-annotation.cc
index 3edcbdb..08044c0 100644
--- a/qt4/src/poppler-annotation.cc
+++ b/qt4/src/poppler-annotation.cc
@@ -1182,7 +1182,6 @@ void Annotation::setContents( const QString &contents )
     GooString *s = QStringToUnicodeGooString(contents);
     d->pdfAnnot->setContents(s);
     delete s;
-    d->pdfAnnot->invalidateAppearance();
 }
 
 QString Annotation::uniqueName() const
@@ -1346,7 +1345,6 @@ void Annotation::setFlags( int flags )
     }
 
     d->pdfAnnot->setFlags(toPdfFlags( flags ));
-    d->pdfAnnot->invalidateAppearance();
 }
 
 QRectF Annotation::boundary() const
@@ -1372,7 +1370,6 @@ void Annotation::setBoundary( const QRectF &boundary )
 
     PDFRectangle rect = d->boundaryToPdfRectangle( boundary, flags() );
     d->pdfAnnot->setRect(&rect);
-    d->pdfAnnot->invalidateAppearance();
 }
 
 Annotation::Style Annotation::style() const
@@ -1453,7 +1450,6 @@ void Annotation::setStyle( const Annotation::Style& style )
     border->setHorizontalCorner( style.xCorners() );
     border->setVerticalCorner( style.yCorners() );
     d->pdfAnnot->setBorder(border);
-    d->pdfAnnot->invalidateAppearance();
 }
 
 Annotation::Popup Annotation::popup() const
@@ -1868,7 +1864,6 @@ void TextAnnotation::setTextIcon( const QString &icon )
         QByteArray encoded = icon.toLatin1();
         GooString s(encoded.constData());
         textann->setIcon(&s);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -1916,7 +1911,6 @@ void TextAnnotation::setTextFont( const QFont &font )
     GooString * da = TextAnnotationPrivate::toAppearanceString(font);
     ftextann->setAppearanceString(da);
     delete da;
-    d->pdfAnnot->invalidateAppearance();
 }
 
 int TextAnnotation::inplaceAlign() const
@@ -1949,7 +1943,6 @@ void TextAnnotation::setInplaceAlign( int align )
     {
         AnnotFreeText * ftextann = static_cast<AnnotFreeText*>(d->pdfAnnot);
         ftextann->setQuadding((AnnotFreeText::AnnotFreeTextQuadding)align);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2018,7 +2011,6 @@ void TextAnnotation::setCalloutPoints( const QVector<QPointF> &points )
     if (count == 0)
     {
         ftextann->setCalloutLine(0);
-        d->pdfAnnot->invalidateAppearance();
         return;
     }
 
@@ -2048,7 +2040,6 @@ void TextAnnotation::setCalloutPoints( const QVector<QPointF> &points )
 
     ftextann->setCalloutLine(callout);
     delete callout;
-    d->pdfAnnot->invalidateAppearance();
 }
 
 TextAnnotation::InplaceIntent TextAnnotation::inplaceIntent() const
@@ -2081,7 +2072,6 @@ void TextAnnotation::setInplaceIntent( TextAnnotation::InplaceIntent intent )
     {
         AnnotFreeText * ftextann = static_cast<AnnotFreeText*>(d->pdfAnnot);
         ftextann->setIntent((AnnotFreeText::AnnotFreeTextIntent)intent);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2366,8 +2356,6 @@ void LineAnnotation::setLinePoints( const QLinkedList<QPointF> &points )
         polyann->setVertices(p);
         delete p;
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 LineAnnotation::TermStyle LineAnnotation::lineStartStyle() const
@@ -2409,8 +2397,6 @@ void LineAnnotation::setLineStartStyle( LineAnnotation::TermStyle style )
         AnnotPolygon *polyann = static_cast<AnnotPolygon*>(d->pdfAnnot);
         polyann->setStartEndStyle((AnnotLineEndingStyle)style, polyann->getEndStyle());
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 LineAnnotation::TermStyle LineAnnotation::lineEndStyle() const
@@ -2452,8 +2438,6 @@ void LineAnnotation::setLineEndStyle( LineAnnotation::TermStyle style )
         AnnotPolygon *polyann = static_cast<AnnotPolygon*>(d->pdfAnnot);
         polyann->setStartEndStyle(polyann->getStartStyle(), (AnnotLineEndingStyle)style);
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 bool LineAnnotation::isLineClosed() const
@@ -2493,8 +2477,6 @@ void LineAnnotation::setLineClosed( bool closed )
             if (polyann->getIntent() == AnnotPolygon::polygonDimension)
                 polyann->setIntent( AnnotPolygon::polylineDimension );
         }
-
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2543,8 +2525,6 @@ void LineAnnotation::setLineInnerColor( const QColor &color )
         AnnotPolygon *polyann = static_cast<AnnotPolygon*>(d->pdfAnnot);
         polyann->setInteriorColor(c);
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 double LineAnnotation::lineLeadingForwardPoint() const
@@ -2577,7 +2557,6 @@ void LineAnnotation::setLineLeadingForwardPoint( double point )
     {
         AnnotLine *lineann = static_cast<AnnotLine*>(d->pdfAnnot);
         lineann->setLeaderLineLength(point);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2611,7 +2590,6 @@ void LineAnnotation::setLineLeadingBackPoint( double point )
     {
         AnnotLine *lineann = static_cast<AnnotLine*>(d->pdfAnnot);
         lineann->setLeaderLineExtension(point);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2645,7 +2623,6 @@ void LineAnnotation::setLineShowCaption( bool show )
     {
         AnnotLine *lineann = static_cast<AnnotLine*>(d->pdfAnnot);
         lineann->setCaption(show);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2702,8 +2679,6 @@ void LineAnnotation::setLineIntent( LineAnnotation::LineIntent intent )
                 polyann->setIntent( AnnotPolygon::polylineDimension );
         }
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 
@@ -2841,8 +2816,6 @@ void GeomAnnotation::setGeomType( GeomAnnotation::GeomType type )
         geomann->setType(Annot::typeSquare);
     else // GeomAnnotation::InscribedCircle
         geomann->setType(Annot::typeCircle);
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 QColor GeomAnnotation::geomInnerColor() const
@@ -2868,7 +2841,6 @@ void GeomAnnotation::setGeomInnerColor( const QColor &color )
 
     AnnotGeometry * geomann = static_cast<AnnotGeometry*>(d->pdfAnnot);
     geomann->setInteriorColor(convertQColor( color ));
-    d->pdfAnnot->invalidateAppearance();
 }
 
 
@@ -3130,7 +3102,6 @@ void HighlightAnnotation::setHighlightType( HighlightAnnotation::HighlightType t
 
     AnnotTextMarkup * hlann = static_cast<AnnotTextMarkup*>(d->pdfAnnot);
     hlann->setType(HighlightAnnotationPrivate::toAnnotSubType( type ));
-    d->pdfAnnot->invalidateAppearance();
 }
 
 QList< HighlightAnnotation::Quad > HighlightAnnotation::highlightQuads() const
@@ -3158,7 +3129,6 @@ void HighlightAnnotation::setHighlightQuads( const QList< HighlightAnnotation::Q
     AnnotQuadrilaterals * quadrilaterals = d->toQuadrilaterals(quads);
     hlann->setQuadrilaterals(quadrilaterals);
     delete quadrilaterals;
-    d->pdfAnnot->invalidateAppearance();
 }
 
 
@@ -3284,7 +3254,6 @@ void StampAnnotation::setStampIconName( const QString &name )
     QByteArray encoded = name.toLatin1();
     GooString s(encoded.constData());
     stampann->setIcon(&s);
-    d->pdfAnnot->invalidateAppearance();
 }
 
 /** InkAnnotation [Annotation] */
@@ -3497,8 +3466,6 @@ void InkAnnotation::setInkPaths( const QList< QLinkedList<QPointF> > &paths )
     for (int i = 0; i < pathsNumber; ++i)
         delete annotpaths[i];
     delete[] annotpaths;
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 
@@ -3966,7 +3933,6 @@ void CaretAnnotation::setCaretSymbol( CaretAnnotation::CaretSymbol symbol )
 
     AnnotCaret * caretann = static_cast<AnnotCaret *>(d->pdfAnnot);
     caretann->setSymbol((AnnotCaret::AnnotCaretSymbol)symbol);
-    d->pdfAnnot->invalidateAppearance();
 }
 
 /** FileAttachmentAnnotation [Annotation] */
diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc
index baf0500..89d33e3 100644
--- a/qt5/src/poppler-annotation.cc
+++ b/qt5/src/poppler-annotation.cc
@@ -1179,7 +1179,6 @@ void Annotation::setContents( const QString &contents )
     GooString *s = QStringToUnicodeGooString(contents);
     d->pdfAnnot->setContents(s);
     delete s;
-    d->pdfAnnot->invalidateAppearance();
 }
 
 QString Annotation::uniqueName() const
@@ -1343,7 +1342,6 @@ void Annotation::setFlags( int flags )
     }
 
     d->pdfAnnot->setFlags(toPdfFlags( flags ));
-    d->pdfAnnot->invalidateAppearance();
 }
 
 QRectF Annotation::boundary() const
@@ -1369,7 +1367,6 @@ void Annotation::setBoundary( const QRectF &boundary )
 
     PDFRectangle rect = d->boundaryToPdfRectangle( boundary, flags() );
     d->pdfAnnot->setRect(&rect);
-    d->pdfAnnot->invalidateAppearance();
 }
 
 Annotation::Style Annotation::style() const
@@ -1450,7 +1447,6 @@ void Annotation::setStyle( const Annotation::Style& style )
     border->setHorizontalCorner( style.xCorners() );
     border->setVerticalCorner( style.yCorners() );
     d->pdfAnnot->setBorder(border);
-    d->pdfAnnot->invalidateAppearance();
 }
 
 Annotation::Popup Annotation::popup() const
@@ -1865,7 +1861,6 @@ void TextAnnotation::setTextIcon( const QString &icon )
         QByteArray encoded = icon.toLatin1();
         GooString s(encoded.constData());
         textann->setIcon(&s);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -1913,7 +1908,6 @@ void TextAnnotation::setTextFont( const QFont &font )
     GooString * da = TextAnnotationPrivate::toAppearanceString(font);
     ftextann->setAppearanceString(da);
     delete da;
-    d->pdfAnnot->invalidateAppearance();
 }
 
 int TextAnnotation::inplaceAlign() const
@@ -1946,7 +1940,6 @@ void TextAnnotation::setInplaceAlign( int align )
     {
         AnnotFreeText * ftextann = static_cast<AnnotFreeText*>(d->pdfAnnot);
         ftextann->setQuadding((AnnotFreeText::AnnotFreeTextQuadding)align);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2005,7 +1998,6 @@ void TextAnnotation::setCalloutPoints( const QVector<QPointF> &points )
     if (count == 0)
     {
         ftextann->setCalloutLine(0);
-        d->pdfAnnot->invalidateAppearance();
         return;
     }
 
@@ -2035,7 +2027,6 @@ void TextAnnotation::setCalloutPoints( const QVector<QPointF> &points )
 
     ftextann->setCalloutLine(callout);
     delete callout;
-    d->pdfAnnot->invalidateAppearance();
 }
 
 TextAnnotation::InplaceIntent TextAnnotation::inplaceIntent() const
@@ -2068,7 +2059,6 @@ void TextAnnotation::setInplaceIntent( TextAnnotation::InplaceIntent intent )
     {
         AnnotFreeText * ftextann = static_cast<AnnotFreeText*>(d->pdfAnnot);
         ftextann->setIntent((AnnotFreeText::AnnotFreeTextIntent)intent);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2353,8 +2343,6 @@ void LineAnnotation::setLinePoints( const QLinkedList<QPointF> &points )
         polyann->setVertices(p);
         delete p;
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 LineAnnotation::TermStyle LineAnnotation::lineStartStyle() const
@@ -2396,8 +2384,6 @@ void LineAnnotation::setLineStartStyle( LineAnnotation::TermStyle style )
         AnnotPolygon *polyann = static_cast<AnnotPolygon*>(d->pdfAnnot);
         polyann->setStartEndStyle((AnnotLineEndingStyle)style, polyann->getEndStyle());
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 LineAnnotation::TermStyle LineAnnotation::lineEndStyle() const
@@ -2439,8 +2425,6 @@ void LineAnnotation::setLineEndStyle( LineAnnotation::TermStyle style )
         AnnotPolygon *polyann = static_cast<AnnotPolygon*>(d->pdfAnnot);
         polyann->setStartEndStyle(polyann->getStartStyle(), (AnnotLineEndingStyle)style);
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 bool LineAnnotation::isLineClosed() const
@@ -2480,8 +2464,6 @@ void LineAnnotation::setLineClosed( bool closed )
             if (polyann->getIntent() == AnnotPolygon::polygonDimension)
                 polyann->setIntent( AnnotPolygon::polylineDimension );
         }
-
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2530,8 +2512,6 @@ void LineAnnotation::setLineInnerColor( const QColor &color )
         AnnotPolygon *polyann = static_cast<AnnotPolygon*>(d->pdfAnnot);
         polyann->setInteriorColor(c);
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 double LineAnnotation::lineLeadingForwardPoint() const
@@ -2564,7 +2544,6 @@ void LineAnnotation::setLineLeadingForwardPoint( double point )
     {
         AnnotLine *lineann = static_cast<AnnotLine*>(d->pdfAnnot);
         lineann->setLeaderLineLength(point);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2598,7 +2577,6 @@ void LineAnnotation::setLineLeadingBackPoint( double point )
     {
         AnnotLine *lineann = static_cast<AnnotLine*>(d->pdfAnnot);
         lineann->setLeaderLineExtension(point);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2632,7 +2610,6 @@ void LineAnnotation::setLineShowCaption( bool show )
     {
         AnnotLine *lineann = static_cast<AnnotLine*>(d->pdfAnnot);
         lineann->setCaption(show);
-        d->pdfAnnot->invalidateAppearance();
     }
 }
 
@@ -2689,8 +2666,6 @@ void LineAnnotation::setLineIntent( LineAnnotation::LineIntent intent )
                 polyann->setIntent( AnnotPolygon::polylineDimension );
         }
     }
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 
@@ -2828,8 +2803,6 @@ void GeomAnnotation::setGeomType( GeomAnnotation::GeomType type )
         geomann->setType(Annot::typeSquare);
     else // GeomAnnotation::InscribedCircle
         geomann->setType(Annot::typeCircle);
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 QColor GeomAnnotation::geomInnerColor() const
@@ -2855,7 +2828,6 @@ void GeomAnnotation::setGeomInnerColor( const QColor &color )
 
     AnnotGeometry * geomann = static_cast<AnnotGeometry*>(d->pdfAnnot);
     geomann->setInteriorColor(convertQColor( color ));
-    d->pdfAnnot->invalidateAppearance();
 }
 
 
@@ -3117,7 +3089,6 @@ void HighlightAnnotation::setHighlightType( HighlightAnnotation::HighlightType t
 
     AnnotTextMarkup * hlann = static_cast<AnnotTextMarkup*>(d->pdfAnnot);
     hlann->setType(HighlightAnnotationPrivate::toAnnotSubType( type ));
-    d->pdfAnnot->invalidateAppearance();
 }
 
 QList< HighlightAnnotation::Quad > HighlightAnnotation::highlightQuads() const
@@ -3145,7 +3116,6 @@ void HighlightAnnotation::setHighlightQuads( const QList< HighlightAnnotation::Q
     AnnotQuadrilaterals * quadrilaterals = d->toQuadrilaterals(quads);
     hlann->setQuadrilaterals(quadrilaterals);
     delete quadrilaterals;
-    d->pdfAnnot->invalidateAppearance();
 }
 
 
@@ -3271,7 +3241,6 @@ void StampAnnotation::setStampIconName( const QString &name )
     QByteArray encoded = name.toLatin1();
     GooString s(encoded.constData());
     stampann->setIcon(&s);
-    d->pdfAnnot->invalidateAppearance();
 }
 
 /** InkAnnotation [Annotation] */
@@ -3484,8 +3453,6 @@ void InkAnnotation::setInkPaths( const QList< QLinkedList<QPointF> > &paths )
     for (int i = 0; i < pathsNumber; ++i)
         delete annotpaths[i];
     delete[] annotpaths;
-
-    d->pdfAnnot->invalidateAppearance();
 }
 
 
@@ -3953,7 +3920,6 @@ void CaretAnnotation::setCaretSymbol( CaretAnnotation::CaretSymbol symbol )
 
     AnnotCaret * caretann = static_cast<AnnotCaret *>(d->pdfAnnot);
     caretann->setSymbol((AnnotCaret::AnnotCaretSymbol)symbol);
-    d->pdfAnnot->invalidateAppearance();
 }
 
 /** FileAttachmentAnnotation [Annotation] */
commit c746e8b38e821d1ebeaf52c4c816515bc3ddaaf6
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Jun 30 11:44:59 2013 +0200

    annots: Remove unused variable

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 5a2671c..420340f 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1082,7 +1082,6 @@ void AnnotAppearanceBBox::extendTo(double x, double y) {
 }
 
 void AnnotAppearanceBBox::getBBoxRect(double bbox[4]) const {
-  Object obj2;
   bbox[0] = minX - borderWidth;
   bbox[1] = minY - borderWidth;
   bbox[2] = maxX + borderWidth;
commit 7d9d5d2518f7760e6a4317a358040ddd9164fdef
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Jun 30 11:40:15 2013 +0200

    annots: Do not update AP and AS entries if they are not present when invaliding the appaearance stream

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index effefdb..5a2671c 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1504,13 +1504,24 @@ void Annot::invalidateAppearance() {
   delete appearStreams;
   appearStreams = NULL;
 
+  delete appearState;
+  appearState = NULL;
+
+  delete appearBBox;
+  appearBBox = NULL;
+
   appearance.free();
   appearance.initNull();
 
-  Object obj1;
+  Object obj1, obj2;
   obj1.initNull();
-  update ("AP", &obj1); // Remove AP
-  update ("AS", &obj1); // Remove AS
+  if (!annotObj.dictLookup("AP", &obj2)->isNull())
+    update ("AP", &obj1); // Remove AP
+  obj2.free();
+
+  if (!annotObj.dictLookup("AS", &obj2)->isNull())
+    update ("AS", &obj1); // Remove AS
+  obj2.free();
 }
 
 double Annot::getXMin() {
commit 347b53f7fca644564724c230fe6c0dcbffa0d6f9
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Jun 30 11:23:54 2013 +0200

    annots: do not set the default appearance state when invalidating appearances
    
    We are setting the default appareance state to Off and then we are
    updating AS dictionary to NULL in the XRef. The appearance state is only
    required when there's more than once appearance stream, but when
    invalidating the apperance we remove all streams.

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 99d40a6..effefdb 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1504,7 +1504,8 @@ void Annot::invalidateAppearance() {
   delete appearStreams;
   appearStreams = NULL;
 
-  setAppearanceState("Off"); // Default appearance state
+  appearance.free();
+  appearance.initNull();
 
   Object obj1;
   obj1.initNull();


More information about the poppler mailing list