[poppler] [Patch] Improve orientation api

Marco Pesenti Gritti mpgritti at gmail.com
Thu Jun 16 10:03:39 PDT 2005


This reworks the api a bit (remove POPPLER_ORIENTATION_DOCUMENT) and
add a getter.

Marco
-------------- next part --------------
? glib/poppler-enums.c
? glib/poppler-enums.h
Index: glib/poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.cc,v
retrieving revision 1.17
diff -u -r1.17 poppler-page.cc
--- glib/poppler-page.cc	4 May 2005 06:32:38 -0000	1.17
+++ glib/poppler-page.cc	16 Jun 2005 17:00:43 -0000
@@ -46,27 +46,6 @@
 
 G_DEFINE_TYPE (PopplerPage, poppler_page, G_TYPE_OBJECT);
 
-PopplerPage *
-_poppler_page_new (PopplerDocument *document, Page *page, int index)
-{
-  PopplerPage *poppler_page;
-
-  g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), NULL);
-
-  poppler_page = (PopplerPage *) g_object_new (POPPLER_TYPE_PAGE, NULL);
-  poppler_page->document = document;
-  poppler_page->page = page;
-  poppler_page->index = index;
-
-  return poppler_page;
-}
-
-static void
-poppler_page_finalize (GObject *object)
-{
-  /* page->page is owned by the document */
-}
-
 static PopplerOrientation
 get_document_orientation (PopplerPage *page)
 {
@@ -90,6 +69,28 @@
   return orientation;
 }
 
+PopplerPage *
+_poppler_page_new (PopplerDocument *document, Page *page, int index)
+{
+  PopplerPage *poppler_page;
+
+  g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), NULL);
+
+  poppler_page = (PopplerPage *) g_object_new (POPPLER_TYPE_PAGE, NULL);
+  poppler_page->document = document;
+  poppler_page->page = page;
+  poppler_page->index = index;
+  poppler_page->orientation = get_document_orientation (poppler_page);
+
+  return poppler_page;
+}
+
+static void
+poppler_page_finalize (GObject *object)
+{
+  /* page->page is owned by the document */
+}
+
 static int
 poppler_page_get_rotate (PopplerPage *page)
 {
@@ -120,18 +121,11 @@
 		       double      *width,
 		       double      *height)
 {
-  PopplerOrientation orientation;
   double page_width, page_height;
 
   g_return_if_fail (POPPLER_IS_PAGE (page));
 
-  if (page->orientation == POPPLER_ORIENTATION_DOCUMENT) {
-    orientation = get_document_orientation (page);
-  } else {
-    orientation = page->orientation;
-  }
-
-  switch (orientation) {
+  switch (page->orientation) {
     case POPPLER_ORIENTATION_PORTRAIT:
     case POPPLER_ORIENTATION_UPSIDEDOWN:
       page_width = page->page->getWidth ();
@@ -544,7 +538,6 @@
 static void
 poppler_page_init (PopplerPage *page)
 {
-  page->orientation = POPPLER_ORIENTATION_DOCUMENT;
 }
 
 
@@ -637,6 +630,22 @@
   page->orientation = orientation;
 }
 
+/**
+ * poppler_page_get_orientation:
+ * @page: a #PopplerPage
+ * @orientation: a #PopplerOrientation
+ *
+ * Return the orientation of the specified page
+ *
+ * Return value: a #PopplerOrientation
+ **/
+PopplerOrientation
+poppler_page_get_orientation (PopplerPage *page)
+{
+  g_return_val_if_fail (POPPLER_IS_PAGE (page), POPPLER_ORIENTATION_PORTRAIT);
+
+  return page->orientation;
+}
 /* PopplerRectangle type */
 
 GType
Index: glib/poppler-page.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.h,v
retrieving revision 1.13
diff -u -r1.13 poppler-page.h
--- glib/poppler-page.h	4 May 2005 06:32:38 -0000	1.13
+++ glib/poppler-page.h	16 Jun 2005 17:00:44 -0000
@@ -32,34 +32,35 @@
 #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,
-					    GdkPixbuf          *pixbuf,
-					    int                 dest_x,
-					    int                 dest_y);
-void       poppler_page_get_size           (PopplerPage        *page,
-					    double             *width,
-					    double             *height);
-void       poppler_page_set_orientation    (PopplerPage        *page,
-					    PopplerOrientation  orientation);
-int        poppler_page_get_index          (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);
+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,
+					             GdkPixbuf          *pixbuf,
+					             int                 dest_x,
+					             int                 dest_y);
+void		    poppler_page_get_size           (PopplerPage        *page,
+					    	     double             *width,
+					             double             *height);
+PopplerOrientation  poppler_page_get_orientation    (PopplerPage        *page);
+void		    poppler_page_set_orientation    (PopplerPage        *page,
+					             PopplerOrientation  orientation);
+int		    poppler_page_get_index          (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);
 
 
 /* A rectangle on a page, with coordinates in PDF points. */
Index: glib/poppler.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler.h,v
retrieving revision 1.8
diff -u -r1.8 poppler.h
--- glib/poppler.h	13 Jun 2005 16:09:33 -0000	1.8
+++ glib/poppler.h	16 Jun 2005 17:00:44 -0000
@@ -36,7 +36,6 @@
 
 typedef enum
 {
-	POPPLER_ORIENTATION_DOCUMENT,
 	POPPLER_ORIENTATION_PORTRAIT,
 	POPPLER_ORIENTATION_LANDSCAPE,
 	POPPLER_ORIENTATION_UPSIDEDOWN,


More information about the poppler mailing list