[poppler] 2 commits - qt4/src

Pino Toscano pino at kemper.freedesktop.org
Sun Apr 13 09:30:49 PDT 2008


 qt4/src/poppler-annotation.cc |   88 ++++++++++++++++++++++++++++++++++++++++++
 qt4/src/poppler-annotation.h  |   29 +++++++++++++
 qt4/src/poppler-page.cc       |   15 ++++++-
 3 files changed, 129 insertions(+), 3 deletions(-)

New commits:
commit ec2cf81edf1b2c6707de4d30316ff5f5e24534d4
Author: Pino Toscano <pino at kde.org>
Date:   Sun Apr 13 18:31:21 2008 +0200

    [Qt4] convert the file attachment annotations

diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index f606ab2..09dca59 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -866,6 +866,18 @@ QList<Annotation*> Page::annotations() const
 
                 break;
             }
+            case Annot::typeFileAttachment:
+            {
+                AnnotFileAttachment * attachann = static_cast< AnnotFileAttachment * >( ann );
+                FileAttachmentAnnotation * f = new FileAttachmentAnnotation();
+                annotation = f;
+                // -> fileIcon
+                f->setFileIconName( QString::fromLatin1( attachann->getName()->getCString() ) );
+                // -> embeddedFile
+                EmbFile *embfile = new EmbFile( attachann->getFile(), attachann->getContents() );
+                f->setEmbeddedFile( new EmbeddedFile( embfile ) );
+                break;
+            }
             // special case for ignoring unknwon annotations
             case Annot::typeUnknown:
                 continue;
@@ -878,7 +890,6 @@ QList<Annotation*> Page::annotations() const
                 QByteArray type;
                 switch ( subType )
                 {
-                    CASE_FOR_TYPE( FileAttachment )
                     CASE_FOR_TYPE( Sound )
                     CASE_FOR_TYPE( Movie )
                     CASE_FOR_TYPE( Widget )
@@ -889,7 +900,7 @@ QList<Annotation*> Page::annotations() const
                     CASE_FOR_TYPE( 3D )
                     default: type = QByteArray::number( subType );
                 }
-                // MISSING: FileAttachment, Sound, Movie, Widget,
+                // MISSING: Sound, Movie, Widget,
                 //          Screen, PrinterMark, TrapNet, Watermark, 3D
                 qDebug() << "Annotation" << type.constData() << "not supported.";
                 continue;
commit 9fa2e96c96d365ae67859545ebd635d726784fca
Author: Pino Toscano <pino at kde.org>
Date:   Sun Apr 13 18:29:00 2008 +0200

    [Qt4] Initial version of FileAttachmentAnnotation

diff --git a/qt4/src/poppler-annotation.cc b/qt4/src/poppler-annotation.cc
index a159edb..d6994d6 100644
--- a/qt4/src/poppler-annotation.cc
+++ b/qt4/src/poppler-annotation.cc
@@ -25,6 +25,7 @@
 // local includes
 #include "poppler-annotation.h"
 #include "poppler-link.h"
+#include "poppler-qt4.h"
 #include "poppler-annotation-private.h"
 
 // poppler includes
@@ -1769,6 +1770,93 @@ void CaretAnnotation::setCaretSymbol( CaretAnnotation::CaretSymbol symbol )
     d->symbol = symbol;
 }
 
+/** FileAttachmentAnnotation [Annotation] */
+class FileAttachmentAnnotationPrivate : public AnnotationPrivate
+{
+    public:
+        FileAttachmentAnnotationPrivate();
+        ~FileAttachmentAnnotationPrivate();
+
+        // data fields
+        QString icon;
+        EmbeddedFile *embfile;
+};
+
+FileAttachmentAnnotationPrivate::FileAttachmentAnnotationPrivate()
+    : AnnotationPrivate(), icon( "PushPin" ), embfile( 0 )
+{
+}
+
+FileAttachmentAnnotationPrivate::~FileAttachmentAnnotationPrivate()
+{
+    delete embfile;
+}
+
+FileAttachmentAnnotation::FileAttachmentAnnotation()
+    : Annotation( *new FileAttachmentAnnotationPrivate() )
+{
+}
+
+FileAttachmentAnnotation::FileAttachmentAnnotation( const QDomNode & node )
+    : Annotation( *new FileAttachmentAnnotationPrivate(), node )
+{
+    // loop through the whole children looking for a 'fileattachment' element
+    QDomNode subNode = node.firstChild();
+    while( subNode.isElement() )
+    {
+        QDomElement e = subNode.toElement();
+        subNode = subNode.nextSibling();
+        if ( e.tagName() != "fileattachment" )
+            continue;
+
+        // loading complete
+        break;
+    }
+}
+
+FileAttachmentAnnotation::~FileAttachmentAnnotation()
+{
+}
+
+void FileAttachmentAnnotation::store( QDomNode & node, QDomDocument & document ) const
+{
+    // recurse to parent objects storing properties
+    Annotation::store( node, document );
+
+    // create [fileattachment] element
+    QDomElement fileAttachmentElement = document.createElement( "fileattachment" );
+    node.appendChild( fileAttachmentElement );
+}
+
+Annotation::SubType FileAttachmentAnnotation::subType() const
+{
+    return AFileAttachment;
+}
+
+QString FileAttachmentAnnotation::fileIconName() const
+{
+    Q_D( const FileAttachmentAnnotation );
+    return d->icon;
+}
+
+void FileAttachmentAnnotation::setFileIconName( const QString &icon )
+{
+    Q_D( FileAttachmentAnnotation );
+    d->icon = icon;
+}
+
+EmbeddedFile* FileAttachmentAnnotation::embeddedFile() const
+{
+    Q_D( const FileAttachmentAnnotation );
+    return d->embfile;
+}
+
+void FileAttachmentAnnotation::setEmbeddedFile( EmbeddedFile *ef )
+{
+    Q_D( FileAttachmentAnnotation );
+    d->embfile = ef;
+}
+
 //BEGIN utility annotation functions
 QColor convertAnnotColor( AnnotColor *color )
 {
diff --git a/qt4/src/poppler-annotation.h b/qt4/src/poppler-annotation.h
index 9511fc7..d47e73f 100644
--- a/qt4/src/poppler-annotation.h
+++ b/qt4/src/poppler-annotation.h
@@ -43,6 +43,8 @@ class StampAnnotationPrivate;
 class InkAnnotationPrivate;
 class LinkAnnotationPrivate;
 class CaretAnnotationPrivate;
+class FileAttachmentAnnotationPrivate;
+class EmbeddedFile;
 class Link;
 
 /**
@@ -88,7 +90,7 @@ 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, A_BASE = 0 };
+                   AInk = 6, ALink = 7, ACaret = 8, AFileAttachment = 9, 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 };
@@ -525,6 +527,31 @@ class POPPLER_QT4_EXPORT CaretAnnotation : public Annotation
     Q_DISABLE_COPY( CaretAnnotation )
 };
 
+/**
+ * \short File attachment annotation.
+ *
+ * The file attachment annotation represents a file embedded in the document.
+ */
+class POPPLER_QT4_EXPORT FileAttachmentAnnotation : public Annotation
+{
+  public:
+    FileAttachmentAnnotation();
+    FileAttachmentAnnotation( const QDomNode &node );
+    virtual ~FileAttachmentAnnotation();
+    virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
+    virtual SubType subType() const;
+
+    QString fileIconName() const;
+    void setFileIconName( const QString &icon );
+
+    EmbeddedFile* embeddedFile() const;
+    void setEmbeddedFile( EmbeddedFile *ef );
+
+  private:
+    Q_DECLARE_PRIVATE( FileAttachmentAnnotation )
+    Q_DISABLE_COPY( FileAttachmentAnnotation )
+};
+
 }
 
 #endif


More information about the poppler mailing list