[poppler] poppler/glib: poppler-page.cc, 1.56, 1.57 poppler-page.h, 1.23, 1.24 poppler.h, 1.13, 1.14 test-poppler-glib.c, 1.19, 1.20

Albert Astals Cid aacid at kemper.freedesktop.org
Fri Apr 27 15:26:11 PDT 2007


Update of /cvs/poppler/poppler/glib
In directory kemper:/tmp/cvs-serv13199/glib

Modified Files:
	poppler-page.cc poppler-page.h poppler.h test-poppler-glib.c 
Log Message:
2007-04-28  Carlos Garcia Campos <carlosgc at gnome.org>
        reviewed and some code by: Albert Astals Cid <aacid at kde.org>

        * glib/poppler-page.cc:
        * glib/poppler-page.h:
        * glib/poppler.h:
        * glib/test-poppler-glib.c:
        * poppler/Makefile.am:
        * poppler/PageTransition.cc:
        * poppler/PageTransition.h:
        * qt/poppler-page-transition.cc:
        * qt/poppler-page-transition.h: Move Page Transition parsing from qt
        frontends to poppler core. Expose Page transitions on the glib
        frontend.


Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.cc,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- poppler-page.cc	27 Apr 2007 21:25:30 -0000	1.56
+++ poppler-page.cc	27 Apr 2007 22:26:09 -0000	1.57
@@ -27,6 +27,7 @@
 #include <ErrorCodes.h>
 #include <UnicodeMap.h>
 #include <GfxState.h>
+#include <PageTransition.h>
 
 #include "poppler.h"
 #include "poppler-private.h"
@@ -141,6 +142,93 @@
   return page->page->getDuration ();
 }
 
+/**
+ * poppler_page_get_transition:
+ * @page: a #PopplerPage
+ *
+ * Returns the transition effect of @page
+ *
+ * Return value: a #PopplerPageTransition or NULL.
+ **/
+PopplerPageTransition *
+poppler_page_get_transition (PopplerPage *page)
+{
+  PageTransition *trans;
+  PopplerPageTransition *transition;
+  Object obj;
+  
+  g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL);
+
+  trans = new PageTransition (page->page->getTrans (&obj));
+  obj.free ();
+
+  if (!trans->isOk ()) {
+    delete trans;
+    return NULL;
+  }
+
+  transition = poppler_page_transition_new ();
+
+  switch (trans->getType ())
+    {
+      case transitionReplace:
+        transition->type = POPPLER_PAGE_TRANSITION_REPLACE;
+	break;
+      case transitionSplit:
+	transition->type = POPPLER_PAGE_TRANSITION_SPLIT;
+	break;
+      case transitionBlinds:
+        transition->type = POPPLER_PAGE_TRANSITION_BLINDS;
+	break;
+      case transitionBox:
+        transition->type = POPPLER_PAGE_TRANSITION_BOX;
+	break;
+      case transitionWipe:
+        transition->type = POPPLER_PAGE_TRANSITION_WIPE;
+	break;
+      case transitionDissolve:
+        transition->type = POPPLER_PAGE_TRANSITION_DISSOLVE;
+	break;
+      case transitionGlitter:
+        transition->type = POPPLER_PAGE_TRANSITION_GLITTER;
+	break;
+      case transitionFly:
+        transition->type = POPPLER_PAGE_TRANSITION_FLY;
+	break;
+      case transitionPush:
+        transition->type = POPPLER_PAGE_TRANSITION_PUSH;
+	break;
+      case transitionCover:
+        transition->type = POPPLER_PAGE_TRANSITION_COVER;
+	break;
+      case transitionUncover:
+        transition->type = POPPLER_PAGE_TRANSITION_UNCOVER;
+        break;
+      case transitionFade:
+        transition->type = POPPLER_PAGE_TRANSITION_FADE;
+	break;
+      default:
+        g_assert_not_reached ();
+    }
+
+  transition->alignment = (trans->getAlignment() == transitionHorizontal) ?
+	  POPPLER_PAGE_TRANSITION_HORIZONTAL :
+	  POPPLER_PAGE_TRANSITION_VERTICAL;
+
+  transition->direction = (trans->getDirection() == transitionInward) ?
+	  POPPLER_PAGE_TRANSITION_INWARD :
+	  POPPLER_PAGE_TRANSITION_OUTWARD;
+
+  transition->duration = trans->getDuration();
+  transition->angle = trans->getAngle();
+  transition->scale = trans->getScale();
+  transition->rectangular = trans->isRectangular();
+  
+  delete trans;
+  
+  return transition;
+}
+
 #if defined (HAVE_CAIRO)
 
 typedef struct {
@@ -1040,6 +1128,40 @@
 	g_free (mapping);
 }
 
+/* Page Transition */
+GType
+poppler_page_transition (void)
+{
+  static GType our_type = 0;
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static("PopplerPageTransition",
+					    (GBoxedCopyFunc) poppler_page_transition_copy,
+					    (GBoxedFreeFunc) poppler_page_transition_free);
+  return our_type;
+}
+
+PopplerPageTransition *
+poppler_page_transition_new (void)
+{
+  return (PopplerPageTransition *) g_new0 (PopplerPageTransition, 1);
+}
+
+PopplerPageTransition *
+poppler_page_transition_copy (PopplerPageTransition *transition)
+{
+  PopplerPageTransition *new_transition;
+
+  new_transition = poppler_page_transition_new ();
+  *new_transition = *transition;
+  
+  return new_transition;
+}
+
+void
+poppler_page_transition_free (PopplerPageTransition *transition)
+{
+  g_free (transition);
+}
 
 /* Form Type */
 GType

Index: poppler-page.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- poppler-page.h	24 Feb 2007 23:32:22 -0000	1.23
+++ poppler-page.h	27 Apr 2007 22:26:09 -0000	1.24
@@ -38,54 +38,55 @@
 #define POPPLER_IS_PAGE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_PAGE))
 
 
-GType      	    poppler_page_get_type           (void) G_GNUC_CONST;
-void                poppler_page_render_to_pixbuf     (PopplerPage        *page,
-						       int                 src_x,
-						       int                 src_y,
-						       int                 src_width,
-						       int                 src_height,
-						       double              scale,
-						       int                 rotation,
-						       GdkPixbuf          *pixbuf);
+GType      	       poppler_page_get_type             (void) G_GNUC_CONST;
+void                   poppler_page_render_to_pixbuf     (PopplerPage        *page,
+							  int                 src_x,
+							  int                 src_y,
+							  int                 src_width,
+							  int                 src_height,
+							  double              scale,
+							  int                 rotation,
+							  GdkPixbuf          *pixbuf);
 
 #ifdef POPPLER_HAS_CAIRO
-void                poppler_page_render               (PopplerPage        *page,
-						       cairo_t            *cairo);
-#endif
+void                   poppler_page_render               (PopplerPage        *page,
+							  cairo_t            *cairo);
+#endif	
 
-void                poppler_page_get_size             (PopplerPage        *page,
-						       double             *width,
-						       double             *height);
-int                 poppler_page_get_index            (PopplerPage        *page);
-double              poppler_page_get_duration         (PopplerPage        *page);
-GdkPixbuf          *poppler_page_get_thumbnail        (PopplerPage        *page);
-gboolean            poppler_page_get_thumbnail_size   (PopplerPage        *page,
-						       int                *width,
-						       int                *height);
-GList     	   *poppler_page_find_text            (PopplerPage        *page,
-						       const  char        *text);
-void                poppler_page_render_to_ps         (PopplerPage        *page,
-						       PopplerPSFile      *ps_file);
-char               *poppler_page_get_text             (PopplerPage        *page,
-						       PopplerRectangle   *rect);
-GList              *poppler_page_get_link_mapping     (PopplerPage        *page);
-void                poppler_page_free_link_mapping    (GList              *list);
-GdkRegion *         poppler_page_get_selection_region (PopplerPage        *page,
-						       gdouble             scale,
-						       PopplerRectangle   *selection);
-void                poppler_page_render_selection     (PopplerPage        *page,
-						       gdouble             scale,
-						       int		   rotation,
-						       GdkPixbuf          *pixbuf,
-						       PopplerRectangle   *selection,
-						       PopplerRectangle   *old_selection,
-						       GdkColor         *glyph_color,
-						       GdkColor         *background_color);
-GList               *poppler_page_get_form_fields     (PopplerPage *page);
-void 	             poppler_page_free_form_fields    (GList *list);
+void                   poppler_page_get_size             (PopplerPage        *page,
+							  double             *width,
+							  double             *height);
+int                    poppler_page_get_index            (PopplerPage        *page);
+double                 poppler_page_get_duration         (PopplerPage        *page);
+PopplerPageTransition *poppler_page_get_transition       (PopplerPage        *page);
+GdkPixbuf             *poppler_page_get_thumbnail        (PopplerPage        *page);
+gboolean               poppler_page_get_thumbnail_size   (PopplerPage        *page,
+							  int                *width,
+							  int                *height);
+GList     	      *poppler_page_find_text            (PopplerPage        *page,
+							  const  char        *text);
+void                   poppler_page_render_to_ps         (PopplerPage        *page,
+							  PopplerPSFile      *ps_file);
+char                  *poppler_page_get_text             (PopplerPage        *page,
+							  PopplerRectangle   *rect);
+GList                 *poppler_page_get_link_mapping     (PopplerPage        *page);
+void                   poppler_page_free_link_mapping    (GList              *list);
+GdkRegion             *poppler_page_get_selection_region (PopplerPage        *page,
+							  gdouble             scale,
+							  PopplerRectangle   *selection);
+void                   poppler_page_render_selection     (PopplerPage        *page,
+							  gdouble             scale,
+							  int		      rotation,
+							  GdkPixbuf          *pixbuf,
+							  PopplerRectangle   *selection,
+							  PopplerRectangle   *old_selection,
+							  GdkColor           *glyph_color,
+							  GdkColor           *background_color);
+GList                 *poppler_page_get_form_fields      (PopplerPage        *page);
+void 	               poppler_page_free_form_fields     (GList              *list);
 
-void 		    poppler_page_get_crop_box 	      (PopplerPage *page,
-						       PopplerRectangle *rect);
+void 		      poppler_page_get_crop_box 	 (PopplerPage        *page,
+							  PopplerRectangle   *rect);
 
 
 /* A rectangle on a page, with coordinates in PDF points. */
@@ -118,6 +119,24 @@
 PopplerLinkMapping *poppler_link_mapping_copy     (PopplerLinkMapping *mapping);
 void                poppler_link_mapping_free     (PopplerLinkMapping *mapping);
 
+/* Page Transition */
+#define POPPLER_TYPE_PAGE_TRANSITION                (poppler_page_transition_get_type ())
+struct _PopplerPageTransition
+{
+  PopplerPageTransitionType type;
+  PopplerPageTransitionAlignment alignment;
+  PopplerPageTransitionDirection direction;
+  gint duration;
+  gint angle;
+  gdouble scale;
+  gboolean rectangular;
+};
+
+GType                  poppler_page_transition_get_type (void) G_GNUC_CONST;
+PopplerPageTransition *poppler_page_transition_new      (void);
+PopplerPageTransition *poppler_page_transition_copy     (PopplerPageTransition *transition);
+void                   poppler_page_transition_free     (PopplerPageTransition *transition);
+
 /* FormField */
 #define POPPLER_TYPE_FORM_FIELD                     (poppler_form_field_get_type ())
 struct _PopplerTextField

Index: poppler.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- poppler.h	24 Feb 2007 23:32:22 -0000	1.13
+++ poppler.h	27 Apr 2007 22:26:09 -0000	1.14
@@ -42,6 +42,34 @@
 	POPPLER_ORIENTATION_SEASCAPE
 } PopplerOrientation;
 
+typedef enum
+{
+  POPPLER_PAGE_TRANSITION_REPLACE,
+  POPPLER_PAGE_TRANSITION_SPLIT,
+  POPPLER_PAGE_TRANSITION_BLINDS,
+  POPPLER_PAGE_TRANSITION_BOX,
+  POPPLER_PAGE_TRANSITION_WIPE,
+  POPPLER_PAGE_TRANSITION_DISSOLVE,
+  POPPLER_PAGE_TRANSITION_GLITTER,
+  POPPLER_PAGE_TRANSITION_FLY,
+  POPPLER_PAGE_TRANSITION_PUSH,
+  POPPLER_PAGE_TRANSITION_COVER,
+  POPPLER_PAGE_TRANSITION_UNCOVER,
+  POPPLER_PAGE_TRANSITION_FADE
+} PopplerPageTransitionType;
+
+typedef enum
+{
+  POPPLER_PAGE_TRANSITION_HORIZONTAL,
+  POPPLER_PAGE_TRANSITION_VERTICAL
+} PopplerPageTransitionAlignment;
+
+typedef enum
+{
+  POPPLER_PAGE_TRANSITION_INWARD,
+  POPPLER_PAGE_TRANSITION_OUTWARD
+} PopplerPageTransitionDirection;
+
 /* MUST be the same than poppler/Form.h fieldType */
 typedef enum
 {
@@ -51,21 +79,21 @@
 	POPPLER_FORM_FIELD_SIGNATURE,
 } PopplerFormFieldType;
 
-
-typedef struct _PopplerDocument    PopplerDocument;
-typedef struct _PopplerIndexIter   PopplerIndexIter;
-typedef struct _PopplerFontsIter   PopplerFontsIter;
-typedef struct _PopplerRectangle   PopplerRectangle;
-typedef struct _PopplerLinkMapping PopplerLinkMapping;
-typedef struct _PopplerFormField   PopplerFormField;
-typedef struct _PopplerPage        PopplerPage;
-typedef struct _PopplerFontInfo    PopplerFontInfo;
-typedef struct _PopplerPSFile      PopplerPSFile;
-typedef union  _PopplerAction      PopplerAction;
-typedef struct _PopplerDest        PopplerDest;
-typedef struct _PopplerTextField PopplerTextField;
-typedef struct _PopplerButtonField PopplerButtonField;
-typedef struct _PopplerChoiceField PopplerChoiceField;
+typedef struct _PopplerDocument       PopplerDocument;
+typedef struct _PopplerIndexIter      PopplerIndexIter;
+typedef struct _PopplerFontsIter      PopplerFontsIter;
+typedef struct _PopplerRectangle      PopplerRectangle;
+typedef struct _PopplerLinkMapping    PopplerLinkMapping;
+typedef struct _PopplerPageTransition PopplerPageTransition;
+typedef struct _PopplerFormField      PopplerFormField;
+typedef struct _PopplerPage           PopplerPage;
+typedef struct _PopplerFontInfo       PopplerFontInfo;
+typedef struct _PopplerPSFile         PopplerPSFile;
+typedef union  _PopplerAction         PopplerAction;
+typedef struct _PopplerDest           PopplerDest;
+typedef struct _PopplerTextField      PopplerTextField;
+typedef struct _PopplerButtonField    PopplerButtonField;
+typedef struct _PopplerChoiceField    PopplerChoiceField;
 
 typedef enum
 {

Index: test-poppler-glib.c
===================================================================
RCS file: /cvs/poppler/poppler/glib/test-poppler-glib.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- test-poppler-glib.c	26 Dec 2006 19:56:29 -0000	1.19
+++ test-poppler-glib.c	27 Apr 2007 22:26:09 -0000	1.20
@@ -109,11 +109,62 @@
   g_free (linearized);
 }
 
+static const gchar *
+transition_effect_name (PopplerPageTransitionType type)
+{
+  switch (type)
+    {
+      case POPPLER_PAGE_TRANSITION_REPLACE:
+	return "Replace";
+      case POPPLER_PAGE_TRANSITION_SPLIT:
+	return "Split";
+      case POPPLER_PAGE_TRANSITION_BLINDS:
+	return "Blinds";
+      case POPPLER_PAGE_TRANSITION_BOX:
+	return "Box";
+      case POPPLER_PAGE_TRANSITION_WIPE:
+	return "Wipe";
+      case POPPLER_PAGE_TRANSITION_DISSOLVE:
+	return "Dissolve";
+      case POPPLER_PAGE_TRANSITION_GLITTER:
+	return "Glitter";
+      case POPPLER_PAGE_TRANSITION_FLY:
+	return "Fly";
+      case POPPLER_PAGE_TRANSITION_PUSH:
+	return "Push";
+      case POPPLER_PAGE_TRANSITION_COVER:
+	return "Cover";
+      case POPPLER_PAGE_TRANSITION_UNCOVER:
+	return "Uncover";
+      case POPPLER_PAGE_TRANSITION_FADE:
+	return "Fade";
+    }
+
+  return "Unknown";
+}
+
+static void
+print_page_transition (PopplerPageTransition *transition)
+{
+  printf ("\t\tEffect: %s\n", transition_effect_name (transition->type));
+  printf ("\t\tAlignment: %s\n",
+	  transition->alignment == POPPLER_PAGE_TRANSITION_HORIZONTAL ?
+	  "Horizontal" : "Vertical");
+  printf ("\t\tDirection: %s\n",
+	  transition->direction == POPPLER_PAGE_TRANSITION_INWARD ?
+	  "Inward" : "Outward");
+  printf ("\t\tDuration: %d\n", transition->duration);
+  printf ("\t\tAngle: %d\n", transition->angle);
+  printf ("\t\tScale: %.2f\n", transition->scale);
+  printf ("\t\tRectangular: %s\n", transition->rectangular ? "Yes" : "No");
+}
+
 int main (int argc, char *argv[])
 {
   PopplerDocument *document;
   PopplerBackend backend;
   PopplerPage *page;
+  PopplerPageTransition *transition;
   GEnumValue *enum_value;
   char *label;
   GError *error;
@@ -154,6 +205,15 @@
   else
     printf ("\tpage duration:\tno duration for page\n");
 
+  transition = poppler_page_get_transition (page);
+  if (transition) {
+    printf ("\tpage transition:\n");
+    print_page_transition (transition);
+    poppler_page_transition_free (transition);
+  } else {
+    printf ("\tpage transition:no transition effect for page\n");
+  }
+
   thumb = poppler_page_get_thumbnail (page);
   if (thumb != NULL) {
     gdk_pixbuf_save (thumb, "thumb.png", "png", &error, NULL);



More information about the poppler mailing list