Poppler Qt4 0.18.1
poppler-annotation.h
00001 /* poppler-annotation.h: qt interface to poppler
00002  * Copyright (C) 2006-2008, Albert Astals Cid <aacid@kde.org>
00003  * Copyright (C) 2006, 2008 Pino Toscano <pino@kde.org>
00004  * Copyright (C) 2007, Brad Hards <bradh@frogmouth.net>
00005  * Copyright (C) 2010, Philip Lorenz <lorenzph+freedesktop@gmail.com>
00006  * Adapting code from
00007  *   Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2, or (at your option)
00012  * any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
00022  */
00023 
00024 #ifndef _POPPLER_ANNOTATION_H_
00025 #define _POPPLER_ANNOTATION_H_
00026 
00027 #include <QtCore/QDateTime>
00028 #include <QtCore/QLinkedList>
00029 #include <QtCore/QList>
00030 #include <QtCore/QPointF>
00031 #include <QtCore/QRectF>
00032 #include <QtGui/QColor>
00033 #include <QtGui/QFont>
00034 #include <QtXml/QDomDocument>
00035 #include "poppler-export.h"
00036 
00037 namespace Poppler {
00038 
00039 class Annotation;
00040 class AnnotationPrivate;
00041 class TextAnnotationPrivate;
00042 class LineAnnotationPrivate;
00043 class GeomAnnotationPrivate;
00044 class HighlightAnnotationPrivate;
00045 class StampAnnotationPrivate;
00046 class InkAnnotationPrivate;
00047 class LinkAnnotationPrivate;
00048 class CaretAnnotationPrivate;
00049 class FileAttachmentAnnotationPrivate;
00050 class SoundAnnotationPrivate;
00051 class MovieAnnotationPrivate;
00052 class EmbeddedFile;
00053 class Link;
00054 class SoundObject;
00055 class MovieObject;
00056 
00061 class POPPLER_QT4_EXPORT AnnotationUtils
00062 {
00063     public:
00070         static Annotation * createAnnotation( const QDomElement & annElement );
00071 
00076         static void storeAnnotation( const Annotation * ann,
00077             QDomElement & annElement, QDomDocument & document );
00078 
00083         static QDomElement findChildElement( const QDomNode & parentNode,
00084             const QString & name );
00085 };
00086 
00087 
00094 class POPPLER_QT4_EXPORT Annotation
00095 {
00096   public:
00097     // enum definitions
00098     // WARNING!!! oKular uses that very same values so if you change them notify the author!
00099     enum SubType { AText = 1, ALine = 2, AGeom = 3, AHighlight = 4, AStamp = 5,
00100                    AInk = 6, ALink = 7, ACaret = 8, AFileAttachment = 9, ASound = 10,
00101                    AMovie = 11, A_BASE = 0 };
00102     enum Flag { Hidden = 1, FixedSize = 2, FixedRotation = 4, DenyPrint = 8,
00103                 DenyWrite = 16, DenyDelete = 32, ToggleHidingOnMouse = 64, External = 128 };
00104     enum LineStyle { Solid = 1, Dashed = 2, Beveled = 4, Inset = 8, Underline = 16 };
00105     enum LineEffect { NoEffect = 1, Cloudy = 2};
00106     enum RevScope { Reply = 1, Group = 2, Delete = 4 };
00107     enum RevType { None = 1,  Marked = 2, Unmarked = 4,  Accepted = 8, Rejected = 16, Cancelled = 32, Completed = 64 };
00108 
00112     QString author() const;
00116     void setAuthor( const QString &author );
00117 
00118     QString contents() const;
00119     void setContents( const QString &contents );
00120 
00124     QString uniqueName() const;
00130     void setUniqueName( const QString &uniqueName );
00131 
00132     QDateTime modificationDate() const;
00133     void setModificationDate( const QDateTime &date );
00134 
00135     QDateTime creationDate() const;
00136     void setCreationDate( const QDateTime &date );
00137 
00138     int flags() const;
00139     void setFlags( int flags );
00140 
00141     QRectF boundary() const;
00142     void setBoundary( const QRectF &boundary );
00143 
00144     struct POPPLER_QT4_EXPORT Style
00145     {
00146         // appearance properties
00147         QColor          color;              // black
00148         double          opacity;            // 1.0
00149         // pen properties
00150         double          width;              // 1.0
00151         LineStyle       style;              // LineStyle::Solid
00152         double          xCorners;           // 0.0
00153         double          yCorners;           // 0.0
00154         int             marks;              // 3
00155         int             spaces;             // 0
00156         // pen effects
00157         LineEffect      effect;             // LineEffect::NoEffect
00158         double          effectIntensity;    // 1.0
00159         // default initializer
00160         Style();
00161     }               style;
00162 
00163     /* properties: popup window */
00164     struct POPPLER_QT4_EXPORT Window
00165     {
00166         // window state (Hidden, FixedRotation, Deny* flags allowed)
00167         int             flags;              // -1 (never initialized) -> 0 (if inited and shown)
00168         // geometric properties
00169         QPointF         topLeft;            // no default, inited to boundary.topLeft
00170         int             width;              // no default
00171         int             height;             // no default
00172         // window contens/override properties
00173         QString         title;              // '' text in the titlebar (overrides author)
00174         QString         summary;            // '' short description (displayed if not empty)
00175         QString         text;               // '' text for the window (overrides annot->contents)
00176         // default initializer
00177         Window();
00178     }               window;
00179 
00180     /* properties: versioning */
00181     struct POPPLER_QT4_EXPORT Revision
00182     {
00183         // child revision
00184         Annotation *    annotation;         // not null
00185         // scope and type of revision
00186         RevScope        scope;              // Reply
00187         RevType         type;               // None
00188         // default initializer
00189         Revision();
00190     };
00191 
00192     QLinkedList< Revision >& revisions();
00193     const QLinkedList< Revision >& revisions() const;
00194 
00195     // methods: query annotation's type for runtime type identification
00199     virtual SubType subType() const = 0;
00200 
00204     virtual void store( QDomNode & parentNode, QDomDocument & document ) const;
00205 
00209     virtual ~Annotation();
00210 
00211   protected:
00213     Annotation( AnnotationPrivate &dd );
00214     Annotation( AnnotationPrivate &dd, const QDomNode &description );
00215     Q_DECLARE_PRIVATE( Annotation )
00216     AnnotationPrivate *d_ptr;
00218 
00219   private:
00220     Q_DISABLE_COPY( Annotation )
00221 };
00222 
00229 class POPPLER_QT4_EXPORT TextAnnotation : public Annotation
00230 {
00231   public:
00232     TextAnnotation();
00233     TextAnnotation( const QDomNode &node );
00234     virtual ~TextAnnotation();
00235     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00236     virtual SubType subType() const;
00237 
00238     // local enums
00239     enum TextType { Linked, InPlace };
00240     enum InplaceIntent { Unknown, Callout, TypeWriter };
00241 
00245     TextType textType() const;
00246 
00250     void setTextType( TextType type );
00251 
00264     QString textIcon() const;
00265 
00271     void setTextIcon( const QString &icon );
00272 
00273     QFont textFont() const;
00274     void setTextFont( const QFont &font );
00275 
00276     int inplaceAlign() const;
00277     void setInplaceAlign( int align );
00278 
00279     QString inplaceText() const;
00280     void setInplaceText( const QString &text );
00281 
00282     QPointF calloutPoint( int id ) const;
00283     void setCalloutPoint( int id, const QPointF &point );
00284 
00285     InplaceIntent inplaceIntent() const;
00286     void setInplaceIntent( InplaceIntent intent );
00287 
00288   private:
00289     Q_DECLARE_PRIVATE( TextAnnotation )
00290     Q_DISABLE_COPY( TextAnnotation )
00291 };
00292 
00298 class POPPLER_QT4_EXPORT LineAnnotation : public Annotation
00299 {
00300   public:
00301     LineAnnotation();
00302     LineAnnotation( const QDomNode &node );
00303     virtual ~LineAnnotation();
00304     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00305     virtual SubType subType() const;
00306 
00307     // local enums
00308     enum TermStyle { Square, Circle, Diamond, OpenArrow, ClosedArrow, None,
00309                      Butt, ROpenArrow, RClosedArrow, Slash };
00310     enum LineIntent { Unknown, Arrow, Dimension, PolygonCloud };
00311 
00312     QLinkedList<QPointF> linePoints() const;
00313     void setLinePoints( const QLinkedList<QPointF> &points );
00314 
00315     TermStyle lineStartStyle() const;
00316     void setLineStartStyle( TermStyle style );
00317 
00318     TermStyle lineEndStyle() const;
00319     void setLineEndStyle( TermStyle style );
00320 
00321     bool isLineClosed() const;
00322     void setLineClosed( bool closed );
00323 
00324     QColor lineInnerColor() const;
00325     void setLineInnerColor( const QColor &color );
00326 
00327     double lineLeadingForwardPoint() const;
00328     void setLineLeadingForwardPoint( double point );
00329 
00330     double lineLeadingBackPoint() const;
00331     void setLineLeadingBackPoint( double point );
00332 
00333     bool lineShowCaption() const;
00334     void setLineShowCaption( bool show );
00335 
00336     LineIntent lineIntent() const;
00337     void setLineIntent( LineIntent intent );
00338 
00339   private:
00340     Q_DECLARE_PRIVATE( LineAnnotation )
00341     Q_DISABLE_COPY( LineAnnotation )
00342 };
00343 
00350 class POPPLER_QT4_EXPORT GeomAnnotation : public Annotation
00351 {
00352   public:
00353     GeomAnnotation();
00354     GeomAnnotation( const QDomNode &node );
00355     virtual ~GeomAnnotation();
00356     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00357     virtual SubType subType() const;
00358 
00359     // common enums
00360     enum GeomType { InscribedSquare, InscribedCircle };
00361 
00362     GeomType geomType() const;
00363     void setGeomType( GeomType style );
00364 
00365     QColor geomInnerColor() const;
00366     void setGeomInnerColor( const QColor &color );
00367 
00368     int geomPointWidth() const;
00369     void setGeomPointWidth( int width );
00370 
00371   private:
00372     Q_DECLARE_PRIVATE( GeomAnnotation )
00373     Q_DISABLE_COPY( GeomAnnotation )
00374 };
00375 
00381 class POPPLER_QT4_EXPORT HighlightAnnotation : public Annotation
00382 {
00383   public:
00384     HighlightAnnotation();
00385     HighlightAnnotation( const QDomNode &node );
00386     virtual ~HighlightAnnotation();
00387     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00388     virtual SubType subType() const;
00389 
00393     enum HighlightType { Highlight, 
00394                          Squiggly,  
00395                          Underline, 
00396                          StrikeOut  
00397     };
00398 
00404     struct Quad
00405     {
00406         QPointF         points[4];          // 8 valid coords
00407         bool            capStart;           // false (vtx 1-4) [K]
00408         bool            capEnd;             // false (vtx 2-3) [K]
00409         double          feather;            // 0.1 (in range 0..1) [K]
00410     };
00411 
00416     HighlightType highlightType() const;
00417 
00422     void setHighlightType( HighlightType type );
00423 
00427     QList< Quad > highlightQuads() const;
00428 
00432     void setHighlightQuads( const QList< Quad > &quads );
00433 
00434   private:
00435     Q_DECLARE_PRIVATE( HighlightAnnotation )
00436     Q_DISABLE_COPY( HighlightAnnotation )
00437 };
00438 
00444 class POPPLER_QT4_EXPORT StampAnnotation : public Annotation
00445 {
00446   public:
00447     StampAnnotation();
00448     StampAnnotation( const QDomNode &node );
00449     virtual ~StampAnnotation();
00450     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00451     virtual SubType subType() const;
00452 
00472     QString stampIconName() const;
00473 
00479     void setStampIconName( const QString &name );
00480 
00481   private:
00482     Q_DECLARE_PRIVATE( StampAnnotation )
00483     Q_DISABLE_COPY( StampAnnotation )
00484 };
00485 
00491 class POPPLER_QT4_EXPORT InkAnnotation : public Annotation
00492 {
00493   public:
00494     InkAnnotation();
00495     InkAnnotation( const QDomNode &node );
00496     virtual ~InkAnnotation();
00497     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00498     virtual SubType subType() const;
00499 
00500     QList< QLinkedList<QPointF> > inkPaths() const;
00501     void setInkPaths( const QList< QLinkedList<QPointF> > &paths );
00502 
00503   private:
00504     Q_DECLARE_PRIVATE( InkAnnotation )
00505     Q_DISABLE_COPY( InkAnnotation )
00506 };
00507 
00508 class POPPLER_QT4_EXPORT LinkAnnotation : public Annotation
00509 {
00510   public:
00511     LinkAnnotation();
00512     LinkAnnotation( const QDomNode &node );
00513     virtual ~LinkAnnotation();
00514     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00515     virtual SubType subType() const;
00516 
00517     // local enums
00518     enum HighlightMode { None, Invert, Outline, Push };
00519 
00520     Link* linkDestionation() const;
00521     void setLinkDestination( Link *link );
00522 
00523     HighlightMode linkHighlightMode() const;
00524     void setLinkHighlightMode( HighlightMode mode );
00525 
00526     QPointF linkRegionPoint( int id ) const;
00527     void setLinkRegionPoint( int id, const QPointF &point );
00528 
00529   private:
00530     Q_DECLARE_PRIVATE( LinkAnnotation )
00531     Q_DISABLE_COPY( LinkAnnotation )
00532 };
00533 
00539 class POPPLER_QT4_EXPORT CaretAnnotation : public Annotation
00540 {
00541   public:
00542     CaretAnnotation();
00543     CaretAnnotation( const QDomNode &node );
00544     virtual ~CaretAnnotation();
00545     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00546     virtual SubType subType() const;
00547 
00551     enum CaretSymbol { None, P };
00552 
00553     CaretSymbol caretSymbol() const;
00554     void setCaretSymbol( CaretSymbol symbol );
00555 
00556   private:
00557     Q_DECLARE_PRIVATE( CaretAnnotation )
00558     Q_DISABLE_COPY( CaretAnnotation )
00559 };
00560 
00568 class POPPLER_QT4_EXPORT FileAttachmentAnnotation : public Annotation
00569 {
00570   public:
00571     FileAttachmentAnnotation();
00572     FileAttachmentAnnotation( const QDomNode &node );
00573     virtual ~FileAttachmentAnnotation();
00574     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00575     virtual SubType subType() const;
00576 
00580     QString fileIconName() const;
00584     void setFileIconName( const QString &icon );
00585 
00589     EmbeddedFile* embeddedFile() const;
00595     void setEmbeddedFile( EmbeddedFile *ef );
00596 
00597   private:
00598     Q_DECLARE_PRIVATE( FileAttachmentAnnotation )
00599     Q_DISABLE_COPY( FileAttachmentAnnotation )
00600 };
00601 
00609 class POPPLER_QT4_EXPORT SoundAnnotation : public Annotation
00610 {
00611   public:
00612     SoundAnnotation();
00613     SoundAnnotation( const QDomNode &node );
00614     virtual ~SoundAnnotation();
00615     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00616     virtual SubType subType() const;
00617 
00621     QString soundIconName() const;
00625     void setSoundIconName( const QString &icon );
00626 
00630     SoundObject* sound() const;
00636     void setSound( SoundObject *ef );
00637 
00638   private:
00639     Q_DECLARE_PRIVATE( SoundAnnotation )
00640     Q_DISABLE_COPY( SoundAnnotation )
00641 };
00642 
00650 class POPPLER_QT4_EXPORT MovieAnnotation : public Annotation
00651 {
00652   public:
00653     MovieAnnotation();
00654     MovieAnnotation( const QDomNode &node );
00655     virtual ~MovieAnnotation();
00656     virtual void store( QDomNode &parentNode, QDomDocument &document ) const;
00657     virtual SubType subType() const;
00658 
00662     MovieObject* movie() const;
00668     void setMovie( MovieObject *movie );
00669 
00673     QString movieTitle() const;
00677     void setMovieTitle( const QString &title );
00678 
00679   private:
00680     Q_DECLARE_PRIVATE( MovieAnnotation )
00681     Q_DISABLE_COPY( MovieAnnotation )
00682 };
00683 
00684 }
00685 
00686 #endif