From 348dd31d89c66383059f6eddc946730954ea505f Mon Sep 17 00:00:00 2001 From: Edward Hades Date: Thu, 1 Sep 2011 17:32:49 +0200 Subject: [PATCH] qt4: partial support for Movie actions Currently, only title-referencing actions are implemented. --- qt4/src/poppler-link.cc | 38 +++++++++++++++++++++++++++++--------- qt4/src/poppler-link.h | 29 +++++++++++++++++++++++------ qt4/src/poppler-page.cc | 36 +++++++++++++++++++++++++++--------- 3 files changed, 79 insertions(+), 24 deletions(-) diff --git a/qt4/src/poppler-link.cc b/qt4/src/poppler-link.cc index 68c607a..c77997f 100644 --- a/qt4/src/poppler-link.cc +++ b/qt4/src/poppler-link.cc @@ -167,18 +167,22 @@ class LinkJavaScriptPrivate : public LinkPrivate { } -#if 0 class LinkMoviePrivate : public LinkPrivate { public: - LinkMoviePrivate( const QRectF &area ); + LinkMoviePrivate( const QRectF &area, bool, const QString&, int, int, LinkMovie::OperationType ); + + QString title; + bool useTitle; + int r, g; + LinkMovie::OperationType type; + }; - LinkMoviePrivate::LinkMoviePrivate( const QRectF &area ) - : LinkPrivate( area ) + LinkMoviePrivate::LinkMoviePrivate( const QRectF &area, bool _useTitle, const QString& _title, int _r, int _g, LinkMovie::OperationType t ) + : LinkPrivate( area ), title(_title), useTitle(_useTitle), r(_r), g(_g), type(t) { } -#endif static void cvtUserToDev(::Page *page, double xu, double yu, int *xd, int *yd) { double ctm[6]; @@ -567,10 +571,9 @@ class LinkMoviePrivate : public LinkPrivate return d->js; } -#if 0 // LinkMovie - LinkMovie::LinkMovie( const QRectF &linkArea ) - : Link( *new LinkMoviePrivate( linkArea ) ) + LinkMovie::LinkMovie( const QRectF &linkArea, OperationType t, bool useTitle, const QString& title, int r, int g ) + : Link( *new LinkMoviePrivate( linkArea, useTitle, title, r, g, t ) ) { } @@ -582,6 +585,23 @@ class LinkMoviePrivate : public LinkPrivate { return Movie; } -#endif + LinkMovie::OperationType LinkMovie::operationType() const + { + Q_D( const LinkMovie ); + return d->type; + } + + bool LinkMovie::isTarget(MovieAnnotation *m) const + { + Q_D( const LinkMovie ); + if ( d->useTitle ) + { + return d->title == m->movieTitle(); + } + else + { + return false; // TODO + } + } } diff --git a/qt4/src/poppler-link.h b/qt4/src/poppler-link.h index 1aa6d78..42a8b15 100644 --- a/qt4/src/poppler-link.h +++ b/qt4/src/poppler-link.h @@ -469,23 +469,40 @@ class POPPLER_QT4_EXPORT LinkJavaScript : public Link private: Q_DECLARE_PRIVATE( LinkJavaScript ) Q_DISABLE_COPY( LinkJavaScript ) -}; +}; + +class MovieAnnotation; -#if 0 -/** Movie: Not yet defined -> think renaming to 'Media' link **/ class POPPLER_QT4_EXPORT LinkMovie : public Link -// TODO this (Movie link) { public: - LinkMovie( const QRectF &linkArea ); + enum OperationType { + Play, + Pause, + Resume, + Stop + }; + + LinkMovie( const QRectF &linkArea, OperationType, bool useTitle, const QString& title, int ref, int gen ); ~LinkMovie(); LinkType linkType() const; + OperationType operationType() const; + + /** + * checks if this movie annotation is the link target. + * + * Since there is no way of referencing between objects in Poppler Qt4, + * you'll have to traverse all your \p MovieAnnotation objects and check, + * if the link applies to them. Start with the annotation on the page, + * you've found the link on, most probably the movie is also there. + */ + bool isTarget(MovieAnnotation* movie) const; + private: Q_DECLARE_PRIVATE( LinkMovie ) Q_DISABLE_COPY( LinkMovie ) }; -#endif } diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc index f76700a..a926766 100644 --- a/qt4/src/poppler-page.cc +++ b/qt4/src/poppler-page.cc @@ -171,15 +171,33 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo break; case actionMovie: -/* TODO this (Movie link) - m_type = Movie; - LinkMovie * m = (LinkMovie *) a; - // copy Movie parameters (2 IDs and a const char *) - Ref * r = m->getAnnotRef(); - m_refNum = r->num; - m_refGen = r->gen; - copyString( m_uri, m->getTitle()->getCString() ); -*/ break; + { + ::LinkMovie *lm = (::LinkMovie *)a; + LinkMovie::OperationType t; + switch ( lm->getOperation() ) + { + case ::LinkMovie::operationTypePlay: + t = LinkMovie::Play; + break; + case ::LinkMovie::operationTypePause: + t = LinkMovie::Pause; + break; + case ::LinkMovie::operationTypeResume: + t = LinkMovie::Resume; + break; + case ::LinkMovie::operationTypeStop: + t = LinkMovie::Stop; + break; + } + if ( lm->hasAnnotTitle() ) + popplerLink = new LinkMovie( linkArea, t, true, UnicodeParsedString(lm->getAnnotTitle()), 0, 0 ); + else if ( lm->hasAnnotRef() ) + { + Ref* r = lm->getAnnotRef(); + popplerLink = new LinkMovie( linkArea, t, true, QString(), r->num, r->gen ); + } + } + break; case actionUnknown: break; -- 1.7.1