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

Pino Toscano pino at kemper.freedesktop.org
Sun Apr 6 03:28:12 PDT 2008


 poppler/Annot.cc              |   11 +++++++----
 poppler/Annot.h               |    9 +++++++--
 qt4/src/poppler-annotation.cc |   35 ++++++++++++++++++++++++++++-------
 qt4/src/poppler-annotation.h  |    7 +++++--
 4 files changed, 47 insertions(+), 15 deletions(-)

New commits:
commit 1d83d6edf9a843335e37a4d1e0e0dd71eb23d93b
Author: Pino Toscano <pino at kde.org>
Date:   Sun Apr 6 12:24:42 2008 +0200

    [Qt4] the caret symbol is an enum value, now

diff --git a/qt4/src/poppler-annotation.cc b/qt4/src/poppler-annotation.cc
index 33c8df2..a159edb 100644
--- a/qt4/src/poppler-annotation.cc
+++ b/qt4/src/poppler-annotation.cc
@@ -1675,11 +1675,32 @@ class CaretAnnotationPrivate : public AnnotationPrivate
         CaretAnnotationPrivate();
 
         // data fields
-        QString symbol;
+        CaretAnnotation::CaretSymbol symbol;
 };
 
+static QString caretSymbolToString( CaretAnnotation::CaretSymbol symbol )
+{
+    switch ( symbol )
+    {
+        case CaretAnnotation::None:
+            return QString::fromLatin1( "None" );
+        case CaretAnnotation::P:
+            return QString::fromLatin1( "P" );
+    }
+    return QString();
+}
+
+static CaretAnnotation::CaretSymbol caretSymbolFromString( const QString &symbol )
+{
+    if ( symbol == QLatin1String( "None" ) )
+        return CaretAnnotation::None;
+    else if ( symbol == QLatin1String( "P" ) )
+        return CaretAnnotation::P;
+    return CaretAnnotation::None;
+}
+
 CaretAnnotationPrivate::CaretAnnotationPrivate()
-    : AnnotationPrivate(), symbol( "None" )
+    : AnnotationPrivate(), symbol( CaretAnnotation::None )
 {
 }
 
@@ -1704,7 +1725,7 @@ CaretAnnotation::CaretAnnotation( const QDomNode & node )
 
         // parse the attributes
         if ( e.hasAttribute( "symbol" ) )
-            d->symbol = e.attribute( "symbol" );
+            d->symbol = caretSymbolFromString( e.attribute( "symbol" ) );
 
         // loading complete
         break;
@@ -1727,8 +1748,8 @@ void CaretAnnotation::store( QDomNode & node, QDomDocument & document ) const
     node.appendChild( caretElement );
 
     // append the optional attributes
-    if ( d->symbol != "None" )
-        caretElement.setAttribute( "symbol", d->symbol );
+    if ( d->symbol != CaretAnnotation::None )
+        caretElement.setAttribute( "symbol", caretSymbolToString( d->symbol ) );
 }
 
 Annotation::SubType CaretAnnotation::subType() const
@@ -1736,13 +1757,13 @@ Annotation::SubType CaretAnnotation::subType() const
     return ACaret;
 }
 
-QString CaretAnnotation::caretSymbol() const
+CaretAnnotation::CaretSymbol CaretAnnotation::caretSymbol() const
 {
     Q_D( const CaretAnnotation );
     return d->symbol;
 }
 
-void CaretAnnotation::setCaretSymbol( const QString &symbol )
+void CaretAnnotation::setCaretSymbol( CaretAnnotation::CaretSymbol symbol )
 {
     Q_D( CaretAnnotation );
     d->symbol = symbol;
diff --git a/qt4/src/poppler-annotation.h b/qt4/src/poppler-annotation.h
index fed389f..9511fc7 100644
--- a/qt4/src/poppler-annotation.h
+++ b/qt4/src/poppler-annotation.h
@@ -514,8 +514,11 @@ class POPPLER_QT4_EXPORT CaretAnnotation : public Annotation
     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
     virtual SubType subType() const;
 
-    QString caretSymbol() const;
-    void setCaretSymbol( const QString &symbol );
+    // local enums
+    enum CaretSymbol { None, P };
+
+    CaretSymbol caretSymbol() const;
+    void setCaretSymbol( CaretSymbol symbol );
 
   private:
     Q_DECLARE_PRIVATE( CaretAnnotation )
commit 229d991a3258cb9b56f5e00f2deb3c976253cf68
Author: Pino Toscano <pino at kde.org>
Date:   Sun Apr 6 12:23:04 2008 +0200

    the caret symbol does not seem to allow additional values, so convert it to an enum

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 5eebb7e..9f6b60e 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -3399,17 +3399,20 @@ AnnotCaret::AnnotCaret(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
 }
 
 AnnotCaret::~AnnotCaret() {
-  delete symbol;
   delete caretRect;
 }
 
 void AnnotCaret::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
   Object obj1;
 
+  symbol = symbolNone;
   if (dict->lookup("Sy", &obj1)->isName()) {
-    symbol = new GooString(obj1.getName());
-  } else {
-    symbol = new GooString("None");
+    GooString typeName(obj1.getName());
+    if (!typeName.cmp("P")) {
+      symbol = symbolP;
+    } else if (!typeName.cmp("None")) {
+      symbol = symbolNone;
+    }
   }
   obj1.free();
 
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 97c9022..ae3d18a 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -958,18 +958,23 @@ private:
 class AnnotCaret: public AnnotMarkup {
 public:
 
+  enum AnnotCaretSymbol {
+    symbolNone,     // None
+    symbolP         // P
+  };
+
   AnnotCaret(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
   ~AnnotCaret();
 
   // getters
-  GooString *getSymbol() const { return symbol; }
+  AnnotCaretSymbol getSymbol() const { return symbol; }
   PDFRectangle *getCaretRect() const { return caretRect; }
 
 private:
 
   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
 
-  GooString *symbol;             // Sy         (Default None)
+  AnnotCaretSymbol symbol;       // Sy         (Default None)
   PDFRectangle *caretRect;       // RD (combined with Rect)
 };
 


More information about the poppler mailing list