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

Pino Toscano pino at kemper.freedesktop.org
Sun Apr 13 12:59:04 PDT 2008


 poppler/Annot.cc              |   37 +++++++++++++++++
 poppler/Annot.h               |   26 ++++++++++++
 qt4/src/poppler-annotation.cc |   87 ++++++++++++++++++++++++++++++++++++++++++
 qt4/src/poppler-annotation.h  |   30 ++++++++++++++
 qt4/src/poppler-page.cc       |   16 ++++++-
 5 files changed, 192 insertions(+), 4 deletions(-)

New commits:
commit f338a9ded5d42dd65853c5c7bbe27f6724096416
Author: Pino Toscano <pino at kde.org>
Date:   Sun Apr 13 21:41:51 2008 +0200

    [Qt4] convert the sound annotations

diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 09dca59..8d14d72 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -878,6 +878,19 @@ QList<Annotation*> Page::annotations() const
                 f->setEmbeddedFile( new EmbeddedFile( embfile ) );
                 break;
             }
+            case Annot::typeSound:
+            {
+                AnnotSound * soundann = static_cast< AnnotSound * >( ann );
+                SoundAnnotation * s = new SoundAnnotation();
+                annotation = s;
+
+                // -> soundIcon
+                s->setSoundIconName( QString::fromLatin1( soundann->getName()->getCString() ) );
+                // -> sound
+                s->setSound( new SoundObject( soundann->getSound() ) );
+
+                break;
+            }
             // special case for ignoring unknwon annotations
             case Annot::typeUnknown:
                 continue;
@@ -890,7 +903,6 @@ QList<Annotation*> Page::annotations() const
                 QByteArray type;
                 switch ( subType )
                 {
-                    CASE_FOR_TYPE( Sound )
                     CASE_FOR_TYPE( Movie )
                     CASE_FOR_TYPE( Widget )
                     CASE_FOR_TYPE( Screen )
@@ -900,7 +912,7 @@ QList<Annotation*> Page::annotations() const
                     CASE_FOR_TYPE( 3D )
                     default: type = QByteArray::number( subType );
                 }
-                // MISSING: Sound, Movie, Widget,
+                // MISSING: Movie, Widget,
                 //          Screen, PrinterMark, TrapNet, Watermark, 3D
                 qDebug() << "Annotation" << type.constData() << "not supported.";
                 continue;
commit 733d51fca04ee682fed2242f868edd545f3755fa
Author: Pino Toscano <pino at kde.org>
Date:   Sun Apr 13 21:38:25 2008 +0200

    [Qt4] First version of a SoundAnnotation.

diff --git a/qt4/src/poppler-annotation.cc b/qt4/src/poppler-annotation.cc
index d6994d6..5e352e4 100644
--- a/qt4/src/poppler-annotation.cc
+++ b/qt4/src/poppler-annotation.cc
@@ -1857,6 +1857,93 @@ void FileAttachmentAnnotation::setEmbeddedFile( EmbeddedFile *ef )
     d->embfile = ef;
 }
 
+/** SoundAnnotation [Annotation] */
+class SoundAnnotationPrivate : public AnnotationPrivate
+{
+    public:
+        SoundAnnotationPrivate();
+        ~SoundAnnotationPrivate();
+
+        // data fields
+        QString icon;
+        SoundObject *sound;
+};
+
+SoundAnnotationPrivate::SoundAnnotationPrivate()
+    : AnnotationPrivate(), icon( "Speaker" ), sound( 0 )
+{
+}
+
+SoundAnnotationPrivate::~SoundAnnotationPrivate()
+{
+    delete sound;
+}
+
+SoundAnnotation::SoundAnnotation()
+    : Annotation( *new SoundAnnotationPrivate() )
+{
+}
+
+SoundAnnotation::SoundAnnotation( const QDomNode & node )
+    : Annotation( *new SoundAnnotationPrivate(), node )
+{
+    // loop through the whole children looking for a 'sound' element
+    QDomNode subNode = node.firstChild();
+    while( subNode.isElement() )
+    {
+        QDomElement e = subNode.toElement();
+        subNode = subNode.nextSibling();
+        if ( e.tagName() != "sound" )
+            continue;
+
+        // loading complete
+        break;
+    }
+}
+
+SoundAnnotation::~SoundAnnotation()
+{
+}
+
+void SoundAnnotation::store( QDomNode & node, QDomDocument & document ) const
+{
+    // recurse to parent objects storing properties
+    Annotation::store( node, document );
+
+    // create [sound] element
+    QDomElement soundElement = document.createElement( "sound" );
+    node.appendChild( soundElement );
+}
+
+Annotation::SubType SoundAnnotation::subType() const
+{
+    return ASound;
+}
+
+QString SoundAnnotation::soundIconName() const
+{
+    Q_D( const SoundAnnotation );
+    return d->icon;
+}
+
+void SoundAnnotation::setSoundIconName( const QString &icon )
+{
+    Q_D( SoundAnnotation );
+    d->icon = icon;
+}
+
+SoundObject* SoundAnnotation::sound() const
+{
+    Q_D( const SoundAnnotation );
+    return d->sound;
+}
+
+void SoundAnnotation::setSound( SoundObject *s )
+{
+    Q_D( SoundAnnotation );
+    d->sound = s;
+}
+
 //BEGIN utility annotation functions
 QColor convertAnnotColor( AnnotColor *color )
 {
diff --git a/qt4/src/poppler-annotation.h b/qt4/src/poppler-annotation.h
index d47e73f..bf0ef67 100644
--- a/qt4/src/poppler-annotation.h
+++ b/qt4/src/poppler-annotation.h
@@ -44,8 +44,10 @@ class InkAnnotationPrivate;
 class LinkAnnotationPrivate;
 class CaretAnnotationPrivate;
 class FileAttachmentAnnotationPrivate;
+class SoundAnnotationPrivate;
 class EmbeddedFile;
 class Link;
+class SoundObject;
 
 /**
  * \short Helper class for (recursive) Annotation retrieval/storage.
@@ -90,7 +92,8 @@ class POPPLER_QT4_EXPORT Annotation
     // enum definitions
     // WARNING!!! oKular uses that very same values so if you change them notify the author!
     enum SubType { AText = 1, ALine = 2, AGeom = 3, AHighlight = 4, AStamp = 5,
-                   AInk = 6, ALink = 7, ACaret = 8, AFileAttachment = 9, A_BASE = 0 };
+                   AInk = 6, ALink = 7, ACaret = 8, AFileAttachment = 9, ASound = 10,
+                   A_BASE = 0 };
     enum Flag { Hidden = 1, FixedSize = 2, FixedRotation = 4, DenyPrint = 8,
                 DenyWrite = 16, DenyDelete = 32, ToggleHidingOnMouse = 64, External = 128 };
     enum LineStyle { Solid = 1, Dashed = 2, Beveled = 4, Inset = 8, Underline = 16 };
@@ -552,6 +555,31 @@ class POPPLER_QT4_EXPORT FileAttachmentAnnotation : public Annotation
     Q_DISABLE_COPY( FileAttachmentAnnotation )
 };
 
+/**
+ * \short Sound annotation.
+ *
+ * The sound annotation represents a sound to be played when activated.
+ */
+class POPPLER_QT4_EXPORT SoundAnnotation : public Annotation
+{
+  public:
+    SoundAnnotation();
+    SoundAnnotation( const QDomNode &node );
+    virtual ~SoundAnnotation();
+    virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
+    virtual SubType subType() const;
+
+    QString soundIconName() const;
+    void setSoundIconName( const QString &icon );
+
+    SoundObject* sound() const;
+    void setSound( SoundObject *ef );
+
+  private:
+    Q_DECLARE_PRIVATE( SoundAnnotation )
+    Q_DISABLE_COPY( SoundAnnotation )
+};
+
 }
 
 #endif
commit feb1ea091111bd7292879c465590acfd7671c876
Author: Pino Toscano <pino at kde.org>
Date:   Sun Apr 13 21:36:26 2008 +0200

    First version of AnnotSound.

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 40ef6f6..7ec7348 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -31,6 +31,7 @@
 #include "XRef.h"
 #include "Movie.h"
 #include "OptionalContent.h"
+#include "Sound.h"
 #include <string.h>
 
 #define annotFlagHidden    0x0002
@@ -3663,6 +3664,40 @@ void AnnotFileAttachment::initialize(XRef *xrefA, Catalog *catalog, Dict* dict)
 }
 
 //------------------------------------------------------------------------
+// AnnotSound
+//------------------------------------------------------------------------
+
+AnnotSound::AnnotSound(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
+  AnnotMarkup(xrefA, dict, catalog, obj) {
+  type = typeSound;
+  initialize(xrefA, catalog, dict);
+}
+
+AnnotSound::~AnnotSound() {
+  delete sound;
+
+  delete name;
+}
+
+void AnnotSound::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
+  Object obj1;
+
+  sound = Sound::parseSound(dict->lookup("Sound", &obj1));
+  if (!sound) {
+    error(-1, "Bad Annot Sound");
+    ok = gFalse;
+  }
+  obj1.free();
+
+  if (dict->lookup("Name", &obj1)->isName()) {
+    name = new GooString(obj1.getName());
+  } else {
+    name = new GooString("Speaker");
+  }
+  obj1.free();
+}
+
+//------------------------------------------------------------------------
 // Annot3D
 //------------------------------------------------------------------------
 
@@ -3855,7 +3890,7 @@ Annot *Annots::createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj
     } else if (!typeName->cmp("FileAttachment")) {
       annot = new AnnotFileAttachment(xref, dict, catalog, obj);
     } else if (!typeName->cmp("Sound")) {
-      annot = new Annot(xref, dict, catalog, obj);
+      annot = new AnnotSound(xref, dict, catalog, obj);
     } else if(!typeName->cmp("Movie")) {
       annot = new AnnotMovie(xref, dict, catalog, obj);
     } else if(!typeName->cmp("Widget")) {
diff --git a/poppler/Annot.h b/poppler/Annot.h
index e37f0f6..f34c2a0 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -24,6 +24,7 @@ class FormWidget;
 class PDFRectangle;
 class Movie;
 class OCGs;
+class Sound;
 
 enum AnnotLineEndingStyle {
   annotLineEndingSquare,        // Square
@@ -1095,6 +1096,31 @@ private:
 };
 
 //------------------------------------------------------------------------
+// AnnotSound
+//------------------------------------------------------------------------
+
+class AnnotSound: public AnnotMarkup {
+public:
+
+  AnnotSound(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
+  ~AnnotSound();
+
+  // getters
+  Sound *getSound() { return sound; }
+  GooString *getName() const { return name; }
+
+private:
+
+  void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
+
+  // required
+  Sound *sound;                  // Sound
+
+  // optional
+  GooString *name;               // Name
+};
+
+//------------------------------------------------------------------------
 // AnnotWidget
 //------------------------------------------------------------------------
 


More information about the poppler mailing list