[poppler] 2 commits - qt5/src

Albert Astals Cid aacid at kemper.freedesktop.org
Thu May 17 22:47:41 UTC 2018


 qt5/src/poppler-annotation.cc |   15 +--------------
 qt5/src/poppler-form.cc       |   20 +++++++++++++++++++-
 qt5/src/poppler-form.h        |    8 ++++++++
 qt5/src/poppler-private.cc    |   18 ++++++++++++++++++
 qt5/src/poppler-private.h     |    2 ++
 5 files changed, 48 insertions(+), 15 deletions(-)

New commits:
commit 921de21733816fc6cd66c70c7a4914fbfee924d6
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri May 18 00:45:59 2018 +0200

    qt5: remove duplicate code
    
    Create new toPopplerAdditionalActionType private function

diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc
index 2394ffc5..5550efcd 100644
--- a/qt5/src/poppler-annotation.cc
+++ b/qt5/src/poppler-annotation.cc
@@ -778,20 +778,7 @@ Link* AnnotationPrivate::additionalAction( Annotation::AdditionalActionType type
     if ( pdfAnnot->getType() != Annot::typeScreen && pdfAnnot->getType() != Annot::typeWidget )
         return nullptr;
 
-    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;
-    }
+    const Annot::AdditionalActionsType actionType = toPopplerAdditionalActionType(type);
 
     ::LinkAction *linkAction = nullptr;
     if ( pdfAnnot->getType() == Annot::typeScreen )
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index 03d04898..9d1b329a 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -1,6 +1,6 @@
 /* poppler-form.h: qt interface to poppler
  * Copyright (C) 2007-2008, 2011, Pino Toscano <pino at kde.org>
- * Copyright (C) 2008, 2011, 2012, 2015-2017 Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2008, 2011, 2012, 2015-2018 Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2011 Carlos Garcia Campos <carlosgc at gnome.org>
  * Copyright (C) 2012, Adam Reichold <adamreichold at myopera.com>
  * Copyright (C) 2016, Hanno Meyer-Thurow <h.mth at web.de>
@@ -212,20 +212,7 @@ Link *FormField::additionalAction(Annotation::AdditionalActionType type) const
     return nullptr;
   }
 
-  Annot::AdditionalActionsType actionType = Annot::actionMouseReleased;
-  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;
-  }
+  const Annot::AdditionalActionsType actionType = toPopplerAdditionalActionType(type);
 
   Link* action = nullptr;
   if (::LinkAction *act = w->getAdditionalAction(actionType))
diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc
index 78751f8e..ca5251df 100644
--- a/qt5/src/poppler-private.cc
+++ b/qt5/src/poppler-private.cc
@@ -163,6 +163,24 @@ namespace Debug {
         return QStringToUnicodeGooString(dt.toUTC().toString("yyyyMMddhhmmss+00'00'"));
     }
 
+    Annot::AdditionalActionsType toPopplerAdditionalActionType(Annotation::AdditionalActionType type) {
+        switch ( type )
+        {
+            case Annotation::CursorEnteringAction:  return Annot::actionCursorEntering;
+            case Annotation::CursorLeavingAction:   return Annot::actionCursorLeaving;
+            case Annotation::MousePressedAction:    return Annot::actionMousePressed;
+            case Annotation::MouseReleasedAction:   return Annot::actionMouseReleased;
+            case Annotation::FocusInAction:         return Annot::actionFocusIn;
+            case Annotation::FocusOutAction:        return Annot::actionFocusOut;
+            case Annotation::PageOpeningAction:     return Annot::actionPageOpening;
+            case Annotation::PageClosingAction:     return Annot::actionPageClosing;
+            case Annotation::PageVisibleAction:     return Annot::actionPageVisible;
+            case Annotation::PageInvisibleAction:   return Annot::actionPageInvisible;
+        }
+
+        return Annot::actionCursorEntering;
+    }
+
     static void linkActionToTocItem( const ::LinkAction * a, DocumentData * doc, QDomElement * e )
     {
         if ( !a || !e )
diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h
index 52715179..9b261d36 100644
--- a/qt5/src/poppler-private.h
+++ b/qt5/src/poppler-private.h
@@ -70,6 +70,8 @@ namespace Poppler {
 
     void qt5ErrorFunction(int pos, char *msg, va_list args);
 
+    Annot::AdditionalActionsType toPopplerAdditionalActionType(Annotation::AdditionalActionType type);
+
     class LinkDestinationData
     {
         public:
commit 083139775fd4ee8dd073347bb0e2835aab334444
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed May 2 16:20:40 2018 +0200

    qt5: Add widget annot actions to FormFields
    
    This adds API to access AnnotWidget actions which
    are associated with a FormField.

diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index 7396b596..03d04898 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -204,6 +204,37 @@ Link *FormField::additionalAction(AdditionalActionType type) const
   return action;
 }
 
+Link *FormField::additionalAction(Annotation::AdditionalActionType type) const
+{
+  ::AnnotWidget *w = m_formData->fm->getWidgetAnnotation();
+  if (!w)
+  {
+    return nullptr;
+  }
+
+  Annot::AdditionalActionsType actionType = Annot::actionMouseReleased;
+  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;
+  }
+
+  Link* action = nullptr;
+  if (::LinkAction *act = w->getAdditionalAction(actionType))
+  {
+    action = PageData::convertLinkActionToLink(act, m_formData->doc, QRectF());
+  }
+  return action;
+}
+
 FormFieldButton::FormFieldButton(DocumentData *doc, ::Page *p, ::FormWidgetButton *w)
   : FormField(*new FormFieldData(doc, p, w))
 {
diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h
index e83deca3..2dc3fe71 100644
--- a/qt5/src/poppler-form.h
+++ b/qt5/src/poppler-form.h
@@ -32,6 +32,7 @@
 #include <QtCore/QStringList>
 #include <QtCore/QSharedPointer>
 #include "poppler-export.h"
+#include "poppler-annotation.h"
 
 class Page;
 class FormWidget;
@@ -153,6 +154,13 @@ namespace Poppler {
 	 */
 	Link* additionalAction(AdditionalActionType type) const;
 
+	/**
+	  * Returns a given widget annotation additional action
+	  *
+	  * \since 0.65
+	 */
+	Link* additionalAction(Annotation::AdditionalActionType type) const;
+
     protected:
 	/// \cond PRIVATE
 	FormField(FormFieldData &dd);


More information about the poppler mailing list