diff options
Diffstat (limited to 'qt4/src')
-rw-r--r-- | qt4/src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | qt4/src/Makefile.am | 7 | ||||
-rw-r--r-- | qt4/src/Makefile.in | 11 | ||||
-rw-r--r-- | qt4/src/poppler-annotation-private.h | 6 | ||||
-rw-r--r-- | qt4/src/poppler-annotation.cc | 105 | ||||
-rw-r--r-- | qt4/src/poppler-annotation.h | 69 | ||||
-rw-r--r-- | qt4/src/poppler-document.cc | 41 | ||||
-rw-r--r-- | qt4/src/poppler-form.cc | 36 | ||||
-rw-r--r-- | qt4/src/poppler-form.h | 15 | ||||
-rw-r--r-- | qt4/src/poppler-link.cc | 60 | ||||
-rw-r--r-- | qt4/src/poppler-link.h | 57 | ||||
-rw-r--r-- | qt4/src/poppler-movie.cc | 15 | ||||
-rw-r--r-- | qt4/src/poppler-page-private.h | 7 | ||||
-rw-r--r-- | qt4/src/poppler-page.cc | 118 | ||||
-rw-r--r-- | qt4/src/poppler-private.h | 69 | ||||
-rw-r--r-- | qt4/src/poppler-qt4.h | 58 |
16 files changed, 575 insertions, 101 deletions
diff --git a/qt4/src/CMakeLists.txt b/qt4/src/CMakeLists.txt index 8b6edaae..b5469542 100644 --- a/qt4/src/CMakeLists.txt +++ b/qt4/src/CMakeLists.txt @@ -30,7 +30,7 @@ set(poppler_qt4_SRCS ) qt4_automoc(${poppler_qt4_SRCS}) add_library(poppler-qt4 SHARED ${poppler_qt4_SRCS}) -set_target_properties(poppler-qt4 PROPERTIES VERSION 4.0.0 SOVERSION 4) +set_target_properties(poppler-qt4 PROPERTIES VERSION 4.2.0 SOVERSION 4) target_link_libraries(poppler-qt4 poppler ${QT4_QTCORE_LIBRARY} ${QT4_QTGUI_LIBRARY} ${QT4_QTXML_LIBRARY}) if(MSVC) target_link_libraries(poppler-qt4 poppler ${poppler_LIBS}) diff --git a/qt4/src/Makefile.am b/qt4/src/Makefile.am index 02e0720d..77426470 100644 --- a/qt4/src/Makefile.am +++ b/qt4/src/Makefile.am @@ -1,8 +1,8 @@ INCLUDES = \ -I$(top_srcdir) \ -I$(top_srcdir)/poppler \ - $(FONTCONFIG_CFLAGS) \ - $(POPPLER_QT4_CFLAGS) + $(POPPLER_QT4_CFLAGS) \ + $(LCMS_CFLAGS) SUFFIXES: .moc @@ -59,10 +59,9 @@ libpoppler_qt4_la_CXXFLAGS = \ libpoppler_qt4_la_LIBADD = \ $(top_builddir)/poppler/libpoppler.la \ $(top_builddir)/poppler/libpoppler-arthur.la \ - $(FONTCONFIG_LIBS) \ $(POPPLER_QT4_LIBS) -libpoppler_qt4_la_LDFLAGS = -version-info 4:0:0 @create_shared_lib@ @auto_import_flags@ +libpoppler_qt4_la_LDFLAGS = -version-info 6:0:2 @create_shared_lib@ @auto_import_flags@ # This rule lets GNU make create any *.moc from the equivalent *.h .h.moc: diff --git a/qt4/src/Makefile.in b/qt4/src/Makefile.in index 63084989..eb6aba33 100644 --- a/qt4/src/Makefile.in +++ b/qt4/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.5 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -104,7 +104,7 @@ am__DEPENDENCIES_1 = libpoppler_qt4_la_DEPENDENCIES = \ $(top_builddir)/poppler/libpoppler.la \ $(top_builddir)/poppler/libpoppler-arthur.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) am_libpoppler_qt4_la_OBJECTS = libpoppler_qt4_la-poppler-document.lo \ libpoppler_qt4_la-poppler-page.lo \ libpoppler_qt4_la-poppler-fontinfo.lo \ @@ -388,8 +388,8 @@ win32_libs = @win32_libs@ INCLUDES = \ -I$(top_srcdir) \ -I$(top_srcdir)/poppler \ - $(FONTCONFIG_CFLAGS) \ - $(POPPLER_QT4_CFLAGS) + $(POPPLER_QT4_CFLAGS) \ + $(LCMS_CFLAGS) poppler_includedir = $(includedir)/poppler/qt4 poppler_include_HEADERS = \ @@ -442,10 +442,9 @@ libpoppler_qt4_la_CXXFLAGS = \ libpoppler_qt4_la_LIBADD = \ $(top_builddir)/poppler/libpoppler.la \ $(top_builddir)/poppler/libpoppler-arthur.la \ - $(FONTCONFIG_LIBS) \ $(POPPLER_QT4_LIBS) -libpoppler_qt4_la_LDFLAGS = -version-info 4:0:0 @create_shared_lib@ @auto_import_flags@ +libpoppler_qt4_la_LDFLAGS = -version-info 6:0:2 @create_shared_lib@ @auto_import_flags@ BUILT_SOURCES = poppler-optcontent.moc all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/qt4/src/poppler-annotation-private.h b/qt4/src/poppler-annotation-private.h index 2ee7d771..3bfb5daf 100644 --- a/qt4/src/poppler-annotation-private.h +++ b/qt4/src/poppler-annotation-private.h @@ -1,7 +1,8 @@ -/* poppler-link-extractor-private.h: qt interface to poppler +/* poppler-annotation-private.h: qt interface to poppler * Copyright (C) 2007, Pino Toscano <pino@kde.org> * Copyright (C) 2012, Tobias Koenig <tokoe@kdab.com> * Copyright (C) 2012, Fabio D'Urso <fabiodurso@hotmail.it> + * Copyright (C) 2012, Albert Astals Cid <aacid@kde.org> * * 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 @@ -31,6 +32,7 @@ class Annot; class AnnotPath; +class Link; class Page; class PDFRectangle; @@ -100,6 +102,8 @@ class AnnotationPrivate : public QSharedData static void removeAnnotationFromPage(::Page *pdfPage, const Annotation * ann); Ref pdfObjectReference() const; + + Link* additionalAction( Annotation::AdditionalActionType type ) const; }; } diff --git a/qt4/src/poppler-annotation.cc b/qt4/src/poppler-annotation.cc index 67dbbae5..5ecea80e 100644 --- a/qt4/src/poppler-annotation.cc +++ b/qt4/src/poppler-annotation.cc @@ -3,6 +3,7 @@ * Copyright (C) 2006, 2008, 2010 Pino Toscano <pino@kde.org> * Copyright (C) 2012, Guillermo A. Amaral B. <gamaral@kde.org> * Copyright (C) 2012, Fabio D'Urso <fabiodurso@hotmail.it> + * Copyright (C) 2012, Tobias Koenig <tokoe@kdab.com> * Adapting code from * Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> * @@ -42,6 +43,7 @@ #include <Gfx.h> #include <Error.h> #include <FileSpec.h> +#include <Link.h> /* Almost all getters directly query the underlying poppler annotation, with * the exceptions of link, file attachment, sound, movie and screen annotations, @@ -455,7 +457,8 @@ QList<Annotation*> AnnotationPrivate::findAnnotations(::Page *pdfPage, DocumentD case Annot::typeUnknown: continue; // special case for ignoring unknown annotations case Annot::typeWidget: - continue; // handled as forms or some other way + annotation = new WidgetAnnotation(); + break; default: { #define CASE_FOR_TYPE( thetype ) \ @@ -493,6 +496,40 @@ Ref AnnotationPrivate::pdfObjectReference() const return pdfAnnot->getRef(); } +Link* AnnotationPrivate::additionalAction( Annotation::AdditionalActionType type ) const +{ + if ( pdfAnnot->getType() != Annot::typeScreen && pdfAnnot->getType() != Annot::typeWidget ) + return 0; + + Annot::AdditionalActionsType actionType = Annot::actionCursorEntering; + switch ( type ) + { + case Annotation::CursorEnteringAction: actionType = Annot::actionCursorEntering; break; + case Annotation::CursorLeavingAction: actionType = Annot::actionCursorLeaving; break; + case Annotation::MousePressedAction: actionType = Annot::actionMousePressed; break; + case Annotation::MouseReleasedAction: actionType = Annot::actionMouseReleased; break; + case Annotation::FocusInAction: actionType = Annot::actionFocusIn; break; + case Annotation::FocusOutAction: actionType = Annot::actionFocusOut; break; + case Annotation::PageOpeningAction: actionType = Annot::actionPageOpening; break; + case Annotation::PageClosingAction: actionType = Annot::actionPageClosing; break; + case Annotation::PageVisibleAction: actionType = Annot::actionPageVisible; break; + case Annotation::PageInvisibleAction: actionType = Annot::actionPageInvisible; break; + } + + ::LinkAction *linkAction = 0; + if ( pdfAnnot->getType() == Annot::typeScreen ) + linkAction = static_cast<AnnotScreen*>( pdfAnnot )->getAdditionalAction( actionType ); + else + linkAction = static_cast<AnnotWidget*>( pdfAnnot )->getAdditionalAction( actionType ); + + Link *link = 0; + + if ( linkAction ) + link = PageData::convertLinkActionToLink( linkAction, parentDoc, QRectF() ); + + return link; +} + void AnnotationPrivate::addAnnotationToPage(::Page *pdfPage, DocumentData *doc, const Annotation * ann) { if (ann->d_ptr->pdfAnnot != 0) @@ -522,14 +559,6 @@ void AnnotationPrivate::removeAnnotationFromPage(::Page *pdfPage, const Annotati return; } - // Remove popup window - AnnotMarkup *markupann = dynamic_cast<AnnotMarkup*>(ann->d_ptr->pdfAnnot); - if (markupann && markupann->getPopup()) - pdfPage->removeAnnot(markupann->getPopup()); - - // Remove appearance streams (if any) - ann->d_ptr->pdfAnnot->invalidateAppearance(); - // Remove annotation pdfPage->removeAnnot(ann->d_ptr->pdfAnnot); @@ -4269,6 +4298,64 @@ void ScreenAnnotation::setScreenTitle( const QString &title ) d->title = title; } +Link* ScreenAnnotation::additionalAction( AdditionalActionType type ) const +{ + Q_D( const ScreenAnnotation ); + return d->additionalAction( type ); +} + +/** WidgetAnnotation [Annotation] */ +class WidgetAnnotationPrivate : public AnnotationPrivate +{ + public: + Annotation * makeAlias(); + Annot* createNativeAnnot(::Page *destPage, DocumentData *doc); +}; + +Annotation * WidgetAnnotationPrivate::makeAlias() +{ + return new WidgetAnnotation(*this); +} + +Annot* WidgetAnnotationPrivate::createNativeAnnot(::Page *destPage, DocumentData *doc) +{ + return 0; // Not implemented +} + +WidgetAnnotation::WidgetAnnotation(WidgetAnnotationPrivate &dd) + : Annotation( dd ) +{} + +WidgetAnnotation::WidgetAnnotation() + : Annotation( *new WidgetAnnotationPrivate() ) +{ +} + +WidgetAnnotation::~WidgetAnnotation() +{ +} + +void WidgetAnnotation::store( QDomNode & node, QDomDocument & document ) const +{ + // store base annotation properties + storeBaseAnnotationProperties( node, document ); + + // create [widget] element + QDomElement widgetElement = document.createElement( "widget" ); + node.appendChild( widgetElement ); +} + +Annotation::SubType WidgetAnnotation::subType() const +{ + return AWidget; +} + +Link* WidgetAnnotation::additionalAction( AdditionalActionType type ) const +{ + Q_D( const WidgetAnnotation ); + return d->additionalAction( type ); +} + //BEGIN utility annotation functions QColor convertAnnotColor( AnnotColor *color ) { diff --git a/qt4/src/poppler-annotation.h b/qt4/src/poppler-annotation.h index e511ec0f..9208ca7a 100644 --- a/qt4/src/poppler-annotation.h +++ b/qt4/src/poppler-annotation.h @@ -55,6 +55,7 @@ class FileAttachmentAnnotationPrivate; class SoundAnnotationPrivate; class MovieAnnotationPrivate; class ScreenAnnotationPrivate; +class WidgetAnnotationPrivate; class EmbeddedFile; class Link; class SoundObject; @@ -106,13 +107,14 @@ class POPPLER_QT4_EXPORT Annotation { friend class AnnotationUtils; friend class LinkMovie; + friend class LinkRendition; public: // 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, ASound = 10, - AMovie = 11, AScreen = 12 /** \since 0.20 */, A_BASE = 0 }; + AMovie = 11, AScreen = 12 /** \since 0.20 */, AWidget = 13 /** \since 0.22 */, 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 }; @@ -272,6 +274,28 @@ class POPPLER_QT4_EXPORT Annotation */ virtual ~Annotation(); + /** + * Describes the flags from an annotations 'AA' dictionary. + * + * This flag is used by the additionalAction() method for ScreenAnnotation + * and WidgetAnnotation. + * + * \since 0.22 + */ + enum AdditionalActionType + { + CursorEnteringAction, ///< Performed when the cursor enters the annotation's active area + CursorLeavingAction, ///< Performed when the cursor exists the annotation's active area + MousePressedAction, ///< Performed when the mouse button is pressed inside the annotation's active area + MouseReleasedAction, ///< Performed when the mouse button is released inside the annotation's active area + FocusInAction, ///< Performed when the annotation receives the input focus + FocusOutAction, ///< Performed when the annotation loses the input focus + PageOpeningAction, ///< Performed when the page containing the annotation is opened + PageClosingAction, ///< Performed when the page containing the annotation is closed + PageVisibleAction, ///< Performed when the page containing the annotation becomes visible + PageInvisibleAction ///< Performed when the page containing the annotation becomes invisible + }; + protected: /// \cond PRIVATE Annotation( AnnotationPrivate &dd ); @@ -840,6 +864,14 @@ class POPPLER_QT4_EXPORT ScreenAnnotation : public Annotation */ void setScreenTitle( const QString &title ); + /** + * Returns the additional action of the given @p type fo the annotation or + * @c 0 if no action has been defined. + * + * \since 0.22 + */ + Link* additionalAction( AdditionalActionType type ) const; + private: ScreenAnnotation(); ScreenAnnotation( ScreenAnnotationPrivate &dd ); @@ -848,6 +880,41 @@ class POPPLER_QT4_EXPORT ScreenAnnotation : public Annotation Q_DISABLE_COPY( ScreenAnnotation ) }; +/** + * \short Widget annotation. + * + * The widget annotation represents a widget (form field) on a page. + * + * \note This class is just provided for consistency of the annotation API, + * use the FormField classes to get all the form-related information. + * + * \since 0.22 + */ +class POPPLER_QT4_EXPORT WidgetAnnotation : public Annotation +{ + friend class AnnotationPrivate; + + public: + virtual ~WidgetAnnotation(); + + virtual SubType subType() const; + + /** + * Returns the additional action of the given @p type fo the annotation or + * @c 0 if no action has been defined. + * + * \since 0.22 + */ + Link* additionalAction( AdditionalActionType type ) const; + + private: + WidgetAnnotation(); + WidgetAnnotation( WidgetAnnotationPrivate &dd ); + virtual void store( QDomNode &parentNode, QDomDocument &document ) const; // stub + Q_DECLARE_PRIVATE( WidgetAnnotation ) + Q_DISABLE_COPY( WidgetAnnotation ) +}; + } #endif diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc index 550e7067..ee56ed69 100644 --- a/qt4/src/poppler-document.cc +++ b/qt4/src/poppler-document.cc @@ -1,10 +1,12 @@ /* poppler-document.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2008, Brad Hards <bradh@frogmouth.net> - * Copyright (C) 2005-2010, Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2005-2010, 2012, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2006-2010, Pino Toscano <pino@kde.org> * Copyright (C) 2010, 2011 Hib Eris <hib@hiberis.nl> * Copyright (C) 2012 Koji Otani <sho@bbr.jp> + * Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> + * Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> * * 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 @@ -519,14 +521,20 @@ namespace Poppler { void Document::setRenderHint( Document::RenderHint hint, bool on ) { + const bool touchesAntialias = hint & ( Document::Antialiasing | Document::TextAntialiasing | Document::TextHinting ); + const bool touchesOverprinting = hint & Document::OverprintPreview; + + int hintForOperation = hint; + if (touchesOverprinting && !isOverprintPreviewAvailable()) + hintForOperation = hintForOperation & ~(int)Document::OverprintPreview; + if ( on ) - m_doc->m_hints |= hint; + m_doc->m_hints |= hintForOperation; else - m_doc->m_hints &= ~(int)hint; + m_doc->m_hints &= ~hintForOperation; // the only way to set antialiasing for Splash is on creation - if ( m_doc->m_backend == Document::SplashBackend && - ( hint & ( Document::Antialiasing || Document::TextAntialiasing || Document::TextHinting ) ) ) + if ( m_doc->m_backend == Document::SplashBackend && (touchesAntialias || touchesOverprinting) ) { delete m_doc->m_outputDev; m_doc->m_outputDev = NULL; @@ -605,6 +613,21 @@ namespace Poppler { return true; } + Document::FormType Document::formType() const + { + switch ( m_doc->doc->getCatalog()->getFormType() ) + { + case Catalog::NoForm: + return Document::NoForm; + case Catalog::AcroForm: + return Document::AcroForm; + case Catalog::XfaForm: + return Document::XfaForm; + } + + return Document::NoForm; // make gcc happy + } + QDateTime convertDate( char *dateString ) { int year, mon, day, hour, min, sec, tzHours, tzMins; @@ -645,4 +668,12 @@ namespace Poppler { #endif } + bool isOverprintPreviewAvailable() { +#if defined(SPLASH_CMYK) + return true; +#else + return false; +#endif + } + } diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc index 82309ff6..a5e5adfc 100644 --- a/qt4/src/poppler-form.cc +++ b/qt4/src/poppler-form.cc @@ -2,6 +2,7 @@ * Copyright (C) 2007-2008, 2011, Pino Toscano <pino@kde.org> * Copyright (C) 2008, 2011, 2012 Albert Astals Cid <aacid@kde.org> * Copyright (C) 2011 Carlos Garcia Campos <carlosgc@gnome.org> + * Copyright (C) 2012, Adam Reichold <adamreichold@myopera.com> * * 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 @@ -226,13 +227,20 @@ void FormFieldButton::setState( bool state ) QList<int> FormFieldButton::siblings() const { FormWidgetButton* fwb = static_cast<FormWidgetButton*>(m_formData->fm); + ::FormFieldButton* ffb = static_cast< ::FormFieldButton* >(fwb->getField()); if (fwb->getButtonType() == formButtonPush) return QList<int>(); QList<int> ret; - unsigned *sibls = fwb->getSiblingsID(); - for (int i = 0; i < fwb->getNumSiblingsID(); ++i) - ret.append(sibls[i]); + for (int i = 0; i < ffb->getNumSiblings(); ++i) + { + ::FormFieldButton* sibling = static_cast< ::FormFieldButton* >(ffb->getSibling(i)); + for (int j = 0; j < sibling->getNumWidgets(); ++j) + { + FormWidget *w = sibling->getWidget(j); + if (w) ret.append(w->getID()); + } + } return ret; } @@ -372,6 +380,28 @@ void FormFieldChoice::setCurrentChoices( const QList<int> &choice ) fwc->select( choice.at( i ) ); } +QString FormFieldChoice::editChoice() const +{ + FormWidgetChoice* fwc = static_cast<FormWidgetChoice*>(m_formData->fm); + + if ( fwc->isCombo() && fwc->hasEdit() ) + return UnicodeParsedString(fwc->getEditChoice()); + else + return QString(); +} + +void FormFieldChoice::setEditChoice(const QString& text) +{ + FormWidgetChoice* fwc = static_cast<FormWidgetChoice*>(m_formData->fm); + + if ( fwc->isCombo() && fwc->hasEdit() ) + { + GooString* goo = QStringToUnicodeGooString( text ); + fwc->setEditChoice( goo ); + delete goo; + } +} + Qt::Alignment FormFieldChoice::textAlignment() const { return formTextAlignment(m_formData->fm); diff --git a/qt4/src/poppler-form.h b/qt4/src/poppler-form.h index 9af367b9..79ed3932 100644 --- a/qt4/src/poppler-form.h +++ b/qt4/src/poppler-form.h @@ -1,6 +1,7 @@ /* poppler-form.h: qt4 interface to poppler * Copyright (C) 2007-2008, Pino Toscano <pino@kde.org> * Copyright (C) 2008, 2011, Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2012, Adam Reichold <adamreichold@myopera.com> * * 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 @@ -305,6 +306,20 @@ namespace Poppler { Sets the selected choices to \p choice. */ void setCurrentChoices( const QList<int> &choice ); + + /** + The text entered into an editable combo box choice field. Otherwise a null string. + + \since 0.22 + */ + QString editChoice() const; + + /** + Sets the text entered into an editable combo box choice field. Otherwise does nothing. + + \since 0.22 + */ + void setEditChoice(const QString& text); /** The horizontal alignment for the text of this text field. diff --git a/qt4/src/poppler-link.cc b/qt4/src/poppler-link.cc index a4bc55b6..199e2dbd 100644 --- a/qt4/src/poppler-link.cc +++ b/qt4/src/poppler-link.cc @@ -168,16 +168,40 @@ class LinkSoundPrivate : public LinkPrivate class LinkRenditionPrivate : public LinkPrivate { public: - LinkRenditionPrivate( const QRectF &area, ::MediaRendition *rendition ); + LinkRenditionPrivate( const QRectF &area, ::MediaRendition *rendition, ::LinkRendition::RenditionOperation operation, const QString &script, const Ref &annotationReference ); ~LinkRenditionPrivate(); MediaRendition *rendition; + LinkRendition::RenditionAction action; + QString script; + Ref annotationReference; }; - LinkRenditionPrivate::LinkRenditionPrivate( const QRectF &area, ::MediaRendition *r ) + LinkRenditionPrivate::LinkRenditionPrivate( const QRectF &area, ::MediaRendition *r, ::LinkRendition::RenditionOperation operation, const QString &javaScript, const Ref &ref ) : LinkPrivate( area ) - , rendition( new MediaRendition( r ) ) + , rendition( r ? new MediaRendition( r ) : 0 ) + , action( LinkRendition::PlayRendition ) + , script( javaScript ) + , annotationReference( ref ) { + switch ( operation ) + { + case ::LinkRendition::NoRendition: + action = LinkRendition::NoRendition; + break; + case ::LinkRendition::PlayRendition: + action = LinkRendition::PlayRendition; + break; + case ::LinkRendition::StopRendition: + action = LinkRendition::StopRendition; + break; + case ::LinkRendition::PauseRendition: + action = LinkRendition::PauseRendition; + break; + case ::LinkRendition::ResumeRendition: + action = LinkRendition::ResumeRendition; + break; + } } LinkRenditionPrivate::~LinkRenditionPrivate() @@ -579,10 +603,15 @@ class LinkMoviePrivate : public LinkPrivate // LinkRendition LinkRendition::LinkRendition( const QRectF &linkArea, ::MediaRendition *rendition ) - : Link( *new LinkRenditionPrivate( linkArea, rendition ) ) + : Link( *new LinkRenditionPrivate( linkArea, rendition, ::LinkRendition::NoRendition, QString(), Ref() ) ) { } + LinkRendition::LinkRendition( const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference ) + : Link( *new LinkRenditionPrivate( linkArea, rendition, static_cast<enum ::LinkRendition::RenditionOperation>(operation), script, annotationReference ) ) + { + } + LinkRendition::~LinkRendition() { } @@ -598,6 +627,29 @@ class LinkMoviePrivate : public LinkPrivate return d->rendition; } + LinkRendition::RenditionAction LinkRendition::action() const + { + Q_D( const LinkRendition ); + return d->action; + } + + QString LinkRendition::script() const + { + Q_D( const LinkRendition ); + return d->script; + } + + bool LinkRendition::isReferencedAnnotation( const ScreenAnnotation *annotation ) const + { + Q_D( const LinkRendition ); + if ( d->annotationReference.num != -1 && d->annotationReference == annotation->d_ptr->pdfObjectReference() ) + { + return true; + } + + return false; + } + // 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 a2ef2d32..ef93bf09 100644 --- a/qt4/src/poppler-link.h +++ b/qt4/src/poppler-link.h @@ -455,12 +455,40 @@ class POPPLER_QT4_EXPORT LinkRendition : public Link { public: /** - * Create a new media rendition link. + * Describes the possible rendition actions. + * + * \since 0.22 + */ + enum RenditionAction { + NoRendition, + PlayRendition, + StopRendition, + PauseRendition, + ResumeRendition + }; + + /** + * Create a new rendition link. + * + * \param linkArea the active area of the link + * \param rendition the media rendition object + * + * \deprecated Use the constructor that takes all parameter instead + */ + Q_DECL_DEPRECATED LinkRendition( const QRectF &linkArea, ::MediaRendition *rendition ); + + /** + * Create a new rendition link. * * \param linkArea the active area of the link - * \param rendition + * \param rendition the media rendition object + * \param operation the numeric operation (action) (@see ::LinkRendition::RenditionOperation) + * \param script the java script code + * \param annotationReference the object reference of the screen annotation associated with this rendition action + * \since 0.22 */ - LinkRendition( const QRectF &linkArea, ::MediaRendition *rendition ); + LinkRendition( const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference ); + /** * Destructor. */ @@ -469,10 +497,31 @@ class POPPLER_QT4_EXPORT LinkRendition : public Link LinkType linkType() const; /** - * + * Returns the media rendition object if the redition provides one, @c 0 otherwise */ MediaRendition *rendition() const; + /** + * Returns the action that should be executed if a rendition object is provided. + * + * \since 0.22 + */ + RenditionAction action() const; + + /** + * The JS code that shall be executed or an empty string. + * + * \since 0.22 + */ + QString script() const; + + /** + * Returns whether the given @p annotation is the referenced screen annotation for this rendition @p link. + * + * \since 0.22 + */ + bool isReferencedAnnotation( const ScreenAnnotation *annotation ) const; + private: Q_DECLARE_PRIVATE( LinkRendition ) Q_DISABLE_COPY( LinkRendition ) diff --git a/qt4/src/poppler-movie.cc b/qt4/src/poppler-movie.cc index 869e3811..a64847c0 100644 --- a/qt4/src/poppler-movie.cc +++ b/qt4/src/poppler-movie.cc @@ -2,6 +2,7 @@ * Copyright (C) 2008, 2010, Pino Toscano <pino@kde.org> * Copyright (C) 2008, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2010, Carlos Garcia Campos <carlosgc@gnome.org> + * Copyright (C) 2012, Tobias Koenig <tobias.koenig@kdab.com> * * 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 @@ -24,6 +25,8 @@ #include "Annot.h" #include "Movie.h" +#include <QtGui/QImage> + namespace Poppler { @@ -43,6 +46,7 @@ public: Movie *m_movieObj; QSize m_size; int m_rotation; + QImage m_posterImage; MovieObject::PlayMode m_playMode : 3; bool m_showControls : 1; }; @@ -51,6 +55,7 @@ MovieObject::MovieObject( AnnotMovie *ann ) { m_movieData = new MovieData(); m_movieData->m_movieObj = ann->getMovie()->copy(); + //TODO: copy poster image MovieActivationParameters *mp = m_movieData->m_movieObj->getActivationParameters(); int width, height; @@ -92,4 +97,14 @@ MovieObject::PlayMode MovieObject::playMode() const return m_movieData->m_playMode; } +bool MovieObject::showPosterImage() const +{ + return (m_movieData->m_movieObj->getShowPoster() == gTrue); +} + +QImage MovieObject::posterImage() const +{ + return m_movieData->m_posterImage; +} + } diff --git a/qt4/src/poppler-page-private.h b/qt4/src/poppler-page-private.h index ecdca170..91955e09 100644 --- a/qt4/src/poppler-page-private.h +++ b/qt4/src/poppler-page-private.h @@ -1,6 +1,6 @@ /* poppler-page.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2007, Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2007, 2012, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2008, Pino Toscano <pino@kde.org> * * This program is free software; you can redistribute it and/or modify @@ -21,10 +21,13 @@ #ifndef _POPPLER_PAGE_PRIVATE_H_ #define _POPPLER_PAGE_PRIVATE_H_ +#include "CharTypes.h" + class QRectF; class LinkAction; class Page; +class TextPage; namespace Poppler { @@ -42,6 +45,8 @@ public: PageTransition *transition; static Link* convertLinkActionToLink(::LinkAction * a, DocumentData *parentDoc, const QRectF &linkArea); + + TextPage *prepareTextSearch(const QString &text, Page::SearchMode caseSensitive, Page::Rotation rotate, GBool *sCase, QVector<Unicode> *u); }; } diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc index 6a16d032..54756146 100644 --- a/qt4/src/poppler-page.cc +++ b/qt4/src/poppler-page.cc @@ -1,7 +1,7 @@ /* poppler-page.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, Brad Hards <bradh@frogmouth.net> - * Copyright (C) 2005-2011, Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2005-2012, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2005, Stefan Kebekus <stefan.kebekus@math.uni-koeln.de> * Copyright (C) 2006-2011, Pino Toscano <pino@kde.org> * Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org> @@ -12,6 +12,8 @@ * Copyright (C) 2010 Hib Eris <hib@hiberis.nl> * Copyright (C) 2012 Tobias Koenig <tokoe@kdab.com> * Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> + * Copyright (C) 2012 Adam Reichold <adamreichold@myopera.com> + * Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> * * 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 @@ -196,7 +198,13 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo case actionRendition: { ::LinkRendition *lrn = (::LinkRendition *)a; - popplerLink = new LinkRendition( linkArea, lrn->getMedia() ); + + Ref reference; + reference.num = reference.gen = -1; + if ( lrn->hasScreenAnnot() ) + reference = lrn->getScreenAnnot(); + + popplerLink = new LinkRendition( linkArea, lrn->getMedia(), lrn->getOperation(), UnicodeParsedString( lrn->getScript() ), reference ); } break; @@ -207,6 +215,25 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo return popplerLink; } +TextPage *PageData::prepareTextSearch(const QString &text, Page::SearchMode caseSensitive, Page::Rotation rotate, GBool *sCase, QVector<Unicode> *u) +{ + const QChar * str = text.unicode(); + const int len = text.length(); + u->resize(len); + for (int i = 0; i < len; ++i) (*u)[i] = str[i].unicode(); + + if (caseSensitive == Page::CaseSensitive) *sCase = gTrue; + else *sCase = gFalse; + + const int rotation = (int)rotate * 90; + + // fetch ourselves a textpage + TextOutputDev td(NULL, gTrue, 0, gFalse, gFalse); + parentDoc->doc->displayPage( &td, index + 1, 72, 72, rotation, false, true, false ); + TextPage *textPage=td.takeText(); + + return textPage; +} Page::Page(DocumentData *doc, int index) { m_page = new PageData(); @@ -240,27 +267,30 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, int bw = bitmap->getWidth(); int bh = bitmap->getHeight(); - SplashColorPtr dataPtr = splash_output->getBitmap()->getDataPtr(); - - if (QSysInfo::BigEndian == QSysInfo::ByteOrder) + if (bitmap->convertToXBGR()) { - uchar c; - int count = bw * bh * 4; - for (int k = 0; k < count; k += 4) - { - c = dataPtr[k]; - dataPtr[k] = dataPtr[k+3]; - dataPtr[k+3] = c; + SplashColorPtr dataPtr = bitmap->getDataPtr(); - c = dataPtr[k+1]; - dataPtr[k+1] = dataPtr[k+2]; - dataPtr[k+2] = c; + if (QSysInfo::BigEndian == QSysInfo::ByteOrder) + { + uchar c; + int count = bw * bh * 4; + for (int k = 0; k < count; k += 4) + { + c = dataPtr[k]; + dataPtr[k] = dataPtr[k+3]; + dataPtr[k+3] = c; + + c = dataPtr[k+1]; + dataPtr[k+1] = dataPtr[k+2]; + dataPtr[k+2] = c; + } } - } - // construct a qimage SHARING the raw bitmap data in memory - QImage tmpimg( dataPtr, bw, bh, QImage::Format_ARGB32 ); - img = tmpimg.copy(); + // construct a qimage SHARING the raw bitmap data in memory + QImage tmpimg( dataPtr, bw, bh, QImage::Format_ARGB32 ); + img = tmpimg.copy(); + } // unload underlying xpdf bitmap splash_output->startPage( 0, NULL ); #endif @@ -376,32 +406,19 @@ QString Page::text(const QRectF &r) const bool Page::search(const QString &text, double &sLeft, double &sTop, double &sRight, double &sBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate) const { - const QChar * str = text.unicode(); - int len = text.length(); - QVector<Unicode> u(len); - for (int i = 0; i < len; ++i) u[i] = str[i].unicode(); - GBool sCase; - if (caseSensitive == CaseSensitive) sCase = gTrue; - else sCase = gFalse; + QVector<Unicode> u; + TextPage *textPage = m_page->prepareTextSearch(text, caseSensitive, rotate, &sCase, &u); bool found = false; - - int rotation = (int)rotate * 90; - - // fetch ourselves a textpage - TextOutputDev td(NULL, gTrue, 0, gFalse, gFalse); - m_page->parentDoc->doc->displayPage( &td, m_page->index + 1, 72, 72, rotation, false, true, false ); - TextPage *textPage=td.takeText(); - if (direction == FromTop) - found = textPage->findText( u.data(), len, + found = textPage->findText( u.data(), u.size(), gTrue, gTrue, gFalse, gFalse, sCase, gFalse, gFalse, &sLeft, &sTop, &sRight, &sBottom ); else if ( direction == NextResult ) - found = textPage->findText( u.data(), len, + found = textPage->findText( u.data(), u.size(), gFalse, gTrue, gTrue, gFalse, sCase, gFalse, gFalse, &sLeft, &sTop, &sRight, &sBottom ); else if ( direction == PreviousResult ) - found = textPage->findText( u.data(), len, + found = textPage->findText( u.data(), u.size(), gFalse, gTrue, gTrue, gFalse, sCase, gTrue, gFalse, &sLeft, &sTop, &sRight, &sBottom ); textPage->decRefCnt(); @@ -427,6 +444,33 @@ bool Page::search(const QString &text, QRectF &rect, SearchDirection direction, return found; } +QList<QRectF> Page::search(const QString &text, SearchMode caseSensitive, Rotation rotate) const +{ + GBool sCase; + QVector<Unicode> u; + TextPage *textPage = m_page->prepareTextSearch(text, caseSensitive, rotate, &sCase, &u); + + QList<QRectF> results; + double sLeft = 0.0, sTop = 0.0, sRight = 0.0, sBottom = 0.0; + + while(textPage->findText( u.data(), u.size(), + gFalse, gTrue, gTrue, gFalse, sCase, gFalse, gFalse, &sLeft, &sTop, &sRight, &sBottom )) + { + QRectF result; + + result.setLeft(sLeft); + result.setTop(sTop); + result.setRight(sRight); + result.setBottom(sBottom); + + results.append(result); + } + + textPage->decRefCnt(); + + return results; +} + QList<TextBox*> Page::textList(Rotation rotate) const { TextOutputDev *output_dev; diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h index 6d2ef2a7..5a9e1b85 100644 --- a/qt4/src/poppler-private.h +++ b/qt4/src/poppler-private.h @@ -1,10 +1,11 @@ /* poppler-private.h: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2008, Brad Hards <bradh@frogmouth.net> - * Copyright (C) 2006-2009, 2011 by Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2006-2009, 2011, 2012 by Albert Astals Cid <aacid@kde.org> * Copyright (C) 2007-2009, 2011 by Pino Toscano <pino@kde.org> * Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> * Copyright (C) 2011 Hib Eris <hib@hiberis.nl> + * Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> * Inspired on code by * Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es> * Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> @@ -124,11 +125,46 @@ namespace Poppler { { #if defined(HAVE_SPLASH) SplashColor bgColor; - bgColor[0] = paperColor.blue(); - bgColor[1] = paperColor.green(); - bgColor[2] = paperColor.red(); + GBool overprint = m_hints & Document::OverprintPreview ? gTrue : gFalse; + globalParams->setOverprintPreview(overprint); +#if defined(SPLASH_CMYK) + if (overprint) + { + Guchar c, m, y, k; + + c = 255 - paperColor.blue(); + m = 255 - paperColor.red(); + y = 255 - paperColor.green(); + k = c; + if (m < k) { + k = m; + } + if (y < k) { + k = y; + } + bgColor[0] = c - k; + bgColor[1] = m - k; + bgColor[2] = y - k; + bgColor[3] = k; + for (int i = 4; i < SPOT_NCOMPS + 4; i++) { + bgColor[i] = 0; + } + } + else +#endif + { + bgColor[0] = paperColor.blue(); + bgColor[1] = paperColor.green(); + bgColor[2] = paperColor.red(); + } GBool AA = m_hints & Document::TextAntialiasing ? gTrue : gFalse; - SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeXBGR8, 4, gFalse, bgColor, gTrue, AA); + SplashOutputDev * splashOutputDev = new SplashOutputDev( +#if defined(SPLASH_CMYK) + (overprint) ? splashModeDeviceN8 : splashModeXBGR8, +#else + splashModeXBGR8, +#endif + 4, gFalse, bgColor, gTrue, AA); splashOutputDev->setVectorAntialias(m_hints & Document::Antialiasing ? gTrue : gFalse); splashOutputDev->setFreeTypeHinting(m_hints & Document::TextHinting ? gTrue : gFalse, m_hints & Document::TextSlightHinting ? gTrue : gFalse); splashOutputDev->startDoc(doc); @@ -149,25 +185,10 @@ namespace Poppler { return; paperColor = color; - if ( m_outputDev == NULL ) - return; - - switch ( m_backend ) - { - case Document::SplashBackend: - { -#if defined(HAVE_SPLASH) - SplashOutputDev *splash_output = static_cast<SplashOutputDev *>( m_outputDev ); - SplashColor bgColor; - bgColor[0] = paperColor.blue(); - bgColor[1] = paperColor.green(); - bgColor[2] = paperColor.red(); - splash_output->setPaperColor(bgColor); -#endif - break; - } - default: ; - } + + // Make sure the new paper color will be picked up for the next rendering + delete m_outputDev; + m_outputDev = NULL; } void fillMembers() diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h index f314108c..f4f6fc65 100644 --- a/qt4/src/poppler-qt4.h +++ b/qt4/src/poppler-qt4.h @@ -11,6 +11,9 @@ * Copyright (C) 2011 Glad Deschrijver <glad.deschrijver@gmail.com> * Copyright (C) 2012, Guillermo A. Amaral B. <gamaral@kde.org> * Copyright (C) 2012, Fabio D'Urso <fabiodurso@hotmail.it> + * Copyright (C) 2012, Tobias Koenig <tobias.koenig@kdab.com> + * Copyright (C) 2012 Adam Reichold <adamreichold@myopera.com> + * Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> * * 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 @@ -601,6 +604,19 @@ delete it; \since 0.14 **/ bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const; + + /** + Returns a list of all occurrences of the specified text on the page. + + \param text the text to search + \param caseSensitive whether to be case sensitive + \param rotate the rotation to apply for the search order + + \warning Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float. + + \since 0.22 + **/ + QList<QRectF> search(const QString &text, SearchMode caseSensitive, Rotation rotate = Rotate0) const; /** Returns a list of text of the page @@ -831,11 +847,23 @@ delete it; Antialiasing = 0x00000001, ///< Antialiasing for graphics TextAntialiasing = 0x00000002, ///< Antialiasing for text TextHinting = 0x00000004, ///< Hinting for text \since 0.12.1 - TextSlightHinting = 0x00000008 ///< Lighter hinting for text when combined with TextHinting \since 0.18 + TextSlightHinting = 0x00000008, ///< Lighter hinting for text when combined with TextHinting \since 0.18 + OverprintPreview = 0x00000010 ///< Overprint preview \since 0.22 }; Q_DECLARE_FLAGS( RenderHints, RenderHint ) /** + Form types + + \since 0.22 + */ + enum FormType { + NoForm, ///< Document doesn't contain forms + AcroForm, ///< AcroForm + XfaForm ///< Adobe XML Forms Architecture (XFA), currently unsupported + }; + + /** Set a color display profile for the current document. \param outputProfileA is a \c cmsHPROFILE of the LCMS library. @@ -1347,6 +1375,13 @@ QString subject = m_doc->info("Subject"); bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const; /** + Returns the type of forms contained in the document + + \since 0.22 + */ + FormType formType() const; + + /** Destructor. */ ~Document(); @@ -1609,6 +1644,13 @@ height = dummy.height(); \since 0.12 */ POPPLER_QT4_EXPORT bool isCmsAvailable(); + + /** + Whether the overprint preview functionality is available. + + \since 0.22 + */ + POPPLER_QT4_EXPORT bool isOverprintPreviewAvailable(); class SoundData; /** @@ -1733,6 +1775,20 @@ height = dummy.height(); */ PlayMode playMode() const; + /** + Returns whether a poster image should be shown if the movie is not playing. + \since 0.22 + */ + bool showPosterImage() const; + + /** + Returns the poster image that should be shown if the movie is not playing. + If the image is null but showImagePoster() returns @c true, the first frame of the movie + should be used as poster image. + \since 0.22 + */ + QImage posterImage() const; + private: /// \cond PRIVATE MovieObject( AnnotMovie *ann ); |