diff --git a/qt4/src/CMakeLists.txt b/qt4/src/CMakeLists.txt index 99dce58..f42b2dc 100644 --- a/qt4/src/CMakeLists.txt +++ b/qt4/src/CMakeLists.txt @@ -25,6 +25,8 @@ set(poppler_qt4_SRCS poppler-sound.cc poppler-textbox.cc poppler-page-transition.cc + poppler-streamdevice.cc + poppler-media.cc ${CMAKE_SOURCE_DIR}/poppler/ArthurOutputDev.cc ) qt4_automoc(${poppler_qt4_SRCS}) @@ -44,5 +46,6 @@ install(FILES poppler-optcontent.h poppler-export.h poppler-page-transition.h + poppler-media.h DESTINATION include/poppler/qt4) diff --git a/qt4/src/poppler-link.cc b/qt4/src/poppler-link.cc index 68c607a..4c29516 100644 --- a/qt4/src/poppler-link.cc +++ b/qt4/src/poppler-link.cc @@ -154,6 +154,20 @@ class LinkSoundPrivate : public LinkPrivate delete sound; } +class LinkRenditionPrivate : public LinkPrivate +{ + public: + LinkRenditionPrivate( const QRectF &area ); + + MediaRendition *rendition; +}; + + LinkRenditionPrivate::LinkRenditionPrivate( const QRectF &area ) + : LinkPrivate( area ) + , rendition( 0 ) + { + } + class LinkJavaScriptPrivate : public LinkPrivate { public: @@ -544,6 +558,29 @@ class LinkMoviePrivate : public LinkPrivate return d->sound; } + // LinkRendition + LinkRendition::LinkRendition( const QRectF &linkArea, MediaRendition *rendition ) + : Link( *new LinkRenditionPrivate( linkArea ) ) + { + Q_D( LinkRendition ); + d->rendition = rendition; + } + + LinkRendition::~LinkRendition() + { + } + + Link::LinkType LinkRendition::linkType() const + { + return Rendition; + } + + MediaRendition * LinkRendition::rendition() const + { + Q_D( const LinkRendition ); + return d->rendition; + } + // LinkJavaScript LinkJavaScript::LinkJavaScript( const QRectF &linkArea, const QString &js ) : Link( *new LinkJavaScriptPrivate( linkArea ) ) diff --git a/qt4/src/poppler-link.h b/qt4/src/poppler-link.h index 1aa6d78..b4887b1 100644 --- a/qt4/src/poppler-link.h +++ b/qt4/src/poppler-link.h @@ -40,7 +40,9 @@ class LinkJavaScriptPrivate; class LinkMoviePrivate; class LinkDestinationData; class LinkDestinationPrivate; +class LinkRenditionPrivate; class SoundObject; +class MediaRendition; /** * \short A destination. @@ -183,6 +185,7 @@ class POPPLER_QT4_EXPORT Link Action, ///< A "standard" action to be executed in the viewer Sound, ///< A link representing a sound to be played Movie, ///< An action to be executed on a movie + Rendition, ///< A rendition link JavaScript ///< A JavaScript code to be interpreted \since 0.10 }; @@ -440,6 +443,36 @@ class POPPLER_QT4_EXPORT LinkSound : public Link }; /** + * Rendition: Rendition link. + */ +class POPPLER_QT4_EXPORT LinkRendition : public Link +{ + public: + /** + * Create a new media rendition link. + * + * \param linkArea the active area of the link + * \param rendition + */ + LinkRendition( const QRectF &linkArea, MediaRendition *rendition ); + /** + * Destructor. + */ + virtual ~LinkRendition(); + + LinkType linkType() const; + + /** + * + */ + MediaRendition *rendition() const; + + private: + Q_DECLARE_PRIVATE( LinkRendition ) + Q_DISABLE_COPY( LinkRendition ) +}; + +/** * JavaScript: a JavaScript code to be interpreted. * * \since 0.10 diff --git a/qt4/src/poppler-media.cc b/qt4/src/poppler-media.cc new file mode 100644 index 0000000..e5a5676 --- /dev/null +++ b/qt4/src/poppler-media.cc @@ -0,0 +1,123 @@ +/* poppler-media.h: qt interface to poppler + * Copyright (C) 2012 Guillermo A. Amaral B. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "poppler-media.h" + +#include "Rendition.h" + +#include "poppler-private.h" +#include "poppler-streamdevice-private.h" + +namespace Poppler +{ + +MediaRendition::MediaRendition(::MediaRendition *rendition) + : m_rendition(rendition) + , m_device(0) +{ + if (m_rendition) + m_device = new StreamDevice(m_rendition->getEmbbededStream()); +} + +MediaRendition::~MediaRendition() +{ + delete m_device; +} + +bool +MediaRendition::isValid() +{ + return m_rendition && m_rendition->isOk(); +} + +MediaParameters* +MediaRendition::getMHParameters() +{ + Q_ASSERT(isValid() && "Invalid media rendition."); + return m_rendition->getMHParameters(); +} + +MediaParameters* +MediaRendition::getBEParameters() +{ + Q_ASSERT(isValid() && "Invalid media rendition."); + return m_rendition->getBEParameters(); +} + +QString +MediaRendition::contentType() +{ + Q_ASSERT(isValid() && "Invalid media rendition."); + return UnicodeParsedString(m_rendition->getContentType()); +} + +QString +MediaRendition::fileName() +{ + Q_ASSERT(isValid() && "Invalid media rendition."); + return UnicodeParsedString(m_rendition->getFileName()); +} + +bool +MediaRendition::isEmbedded() +{ + Q_ASSERT(isValid() && "Invalid media rendition."); + return m_rendition->getIsEmbedded(); +} + +QIODevice * +MediaRendition::streamDevice() const +{ + return m_device; +} + +bool +MediaRendition::autoPlay() const +{ + if (m_rendition->getBEParameters()) { + return m_rendition->getBEParameters()->autoPlay; + } else if (m_rendition->getMHParameters()) { + return m_rendition->getMHParameters()->autoPlay; + } else qDebug("No BE or MH paremeters to reference!"); + return false; +} + +bool +MediaRendition::showControls() const +{ + if (m_rendition->getBEParameters()) { + return m_rendition->getBEParameters()->showControls; + } else if (m_rendition->getMHParameters()) { + return m_rendition->getMHParameters()->showControls; + } else qDebug("No BE or MH paremeters to reference!"); + return false; +} + +float +MediaRendition::repeatCount() const +{ + if (m_rendition->getBEParameters()) { + return m_rendition->getBEParameters()->repeatCount; + } else if (m_rendition->getMHParameters()) { + return m_rendition->getMHParameters()->repeatCount; + } else qDebug("No BE or MH paremeters to reference!"); + return 1.f; +} + +} + diff --git a/qt4/src/poppler-media.h b/qt4/src/poppler-media.h new file mode 100644 index 0000000..b9843ec --- /dev/null +++ b/qt4/src/poppler-media.h @@ -0,0 +1,58 @@ +/* poppler-media-private.h: qt interface to poppler + * Copyright (C) 2012 Guillermo A. Amaral B. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __POPPLER_MEDIARENDITION_H__ +#define __POPPLER_MEDIARENDITION_H__ + +#include + +class MediaRendition; +class QIODevice; + +struct MediaParameters; + +namespace Poppler +{ + class MediaRendition { + public: + MediaRendition(::MediaRendition *rendition); + ~MediaRendition(); + + bool isValid(); + + MediaParameters* getMHParameters(); + MediaParameters* getBEParameters(); + + QString contentType(); + QString fileName(); + + bool isEmbedded(); + QIODevice *streamDevice() const; + + /* helper function */ + bool autoPlay() const; + bool showControls() const; + float repeatCount() const; + + private: + ::MediaRendition *m_rendition; + QIODevice *m_device; + }; +} + +#endif /* __POPPLER_MEDIARENDITION_H__ */ diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc index 398a69b..2796011 100644 --- a/qt4/src/poppler-page.cc +++ b/qt4/src/poppler-page.cc @@ -44,6 +44,7 @@ #include #include #include +#include #if defined(HAVE_SPLASH) #include #include @@ -56,6 +57,8 @@ #include "poppler-annotation-helper.h" #include "poppler-annotation-private.h" #include "poppler-form.h" +#include "poppler-media.h" +#include "poppler-streamdevice-private.h" namespace Poppler { @@ -180,6 +183,12 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo m_refGen = r->gen; copyString( m_uri, m->getTitle()->getCString() ); */ break; + case actionRendition: + { + ::LinkRendition *lrn = (::LinkRendition *)a; + popplerLink = new LinkRendition( linkArea, new MediaRendition(lrn->getMedia()) ); + } + break; case actionUnknown: break; @@ -981,6 +990,21 @@ QList Page::annotations() const // handled as forms or some other way case Annot::typeWidget: continue; + case Annot::typeScreen: + { + AnnotScreen * screenann = static_cast< AnnotScreen * >( ann ); + + const GooString *title = screenann->getTitle(); + if (title) + qDebug("tokoe: title: %s", title->getCString()); + + if (screenann->getAction()) { + Link * popplerLink = m_page->convertLinkActionToLink( screenann->getAction(), QRectF() ); + } + + qDebug("appear=%p action=%p additionalAction=%p", screenann->getAppearCharacs(), screenann->getAction(), screenann->getAdditionActions()); + } + continue; default: { #define CASE_FOR_TYPE( thetype ) \ diff --git a/qt4/src/poppler-streamdevice-private.h b/qt4/src/poppler-streamdevice-private.h new file mode 100644 index 0000000..0c2adc5 --- /dev/null +++ b/qt4/src/poppler-streamdevice-private.h @@ -0,0 +1,48 @@ +/* poppler-streamdevice-private.h: Qt4 interface to poppler + * Copyright (C) 2012, Guiillermo A. Amaral B. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef POPPLER_STREAMDEVICE_PRIVATE_H +#define POPPLER_STREAMDEVICE_PRIVATE_H + +#include + +class Stream; + +namespace Poppler { + +class StreamDevice : public QIODevice +{ + public: + StreamDevice(Stream *stream, QObject *parent = 0); + virtual ~StreamDevice(); + + virtual bool isSequential() const + { return true; } + + protected: + virtual qint64 readData(char *data, qint64 maxSize); + inline virtual qint64 writeData(const char *, qint64) + { return 0; } + + private: + Stream *m_stream; +}; + +} + +#endif diff --git a/qt4/src/poppler-streamdevice.cc b/qt4/src/poppler-streamdevice.cc new file mode 100644 index 0000000..69da072 --- /dev/null +++ b/qt4/src/poppler-streamdevice.cc @@ -0,0 +1,49 @@ +/* poppler-streamdevice.cc: Qt4 interface to poppler + * Copyright (C) 2012, Guiillermo A. Amaral B. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "poppler-streamdevice-private.h" + +#include "Object.h" +#include "Stream.h" + +namespace Poppler { + +StreamDevice::StreamDevice(Stream *stream, QObject *parent) + : QIODevice(parent) + , m_stream(stream) +{ + Q_ASSERT(m_stream && "Invalid stream assigned."); + m_stream->incRef(); + m_stream->reset(); + setOpenMode(QIODevice::ReadOnly); +} + +StreamDevice::~StreamDevice() +{ + m_stream->decRef(); + m_stream = 0; +} + +qint64 +StreamDevice::readData(char *data, qint64 maxSize) +{ + return m_stream->doGetChars(maxSize, reinterpret_cast(data)); +} + +} +