[poppler] poppler/qt: poppler-page-transition.cc, 1.5, 1.6 poppler-page-transition.h, 1.2, 1.3

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


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

Modified Files:
	poppler-page-transition.cc poppler-page-transition.h 
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-transition.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-page-transition.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- poppler-page-transition.cc	25 Apr 2007 19:59:10 -0000	1.5
+++ poppler-page-transition.cc	27 Apr 2007 22:26:09 -0000	1.6
@@ -16,8 +16,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#include "Object.h"
-#include "Error.h"
+#include "PageTransition.h"
 #include "poppler-page-transition.h"
 #include "poppler-page-transition-private.h"
 
@@ -26,124 +25,32 @@
 class PageTransitionData
 {
   public:
-    PageTransition::Type type;
-    int duration;
-    PageTransition::Alignment alignment;
-    PageTransition::Direction direction;
-    int angle;
-    double scale;
-    bool rectangular;
-};
-
-PageTransition::PageTransition(const PageTransitionParams &params)
-{
-  data = new PageTransitionData();
-  data->type = Replace;
-  data->duration = 1;
-  data->alignment = Horizontal;
-  data->direction = Inward;
-  data->angle = 0;
-  data->scale = 1.0;
-  data->rectangular = false;
+    PageTransitionData(Object *trans)
+    {
+        pt = new ::PageTransition(trans);
+    }
 
-  // Paranoid safety checks
-  if (params.dictObj == 0) {
-    error(-1, "the method PageTransition_x::PageTransition_x(Object *params.dictObj) was called with params.dictObj==0\n");
-    return;
-  }
-  if (params.dictObj->isDict() == false) {
-    error(-1, "the method PageTransition_x::PageTransition_x(Object *params.dictObj) was called where params.dictObj->isDict()==false\n");
-    return;
-  }
+    PageTransitionData(const PageTransitionData &ptd)
+    {
+        pt = new ::PageTransition(*ptd.pt);
+    }
 
-  // Obtain a pointer to the dictionary and start parsing.
-  Dict *transDict = params.dictObj->getDict();
-  Object obj;
+    ~PageTransitionData()
+    {
+        delete pt;
+    }
 
-  if (transDict->lookup("S", &obj)->isName()) {
-    const char *s = obj.getName();
-    if (strcmp("R", s) == 0)
-      data->type = Replace;
-    else if (strcmp("Split", s) == 0)
-      data->type = Split;
-    else if (strcmp("Blinds", s) == 0)
-      data->type = Blinds;
-    else if (strcmp("Box", s) == 0)
-      data->type = Box;
-    else if (strcmp("Wipe", s) == 0)
-      data->type = Wipe;
-    else if (strcmp("Dissolve", s) == 0)
-      data->type = Dissolve;
-    else if (strcmp("Glitter", s) == 0)
-      data->type = Glitter;
-    else if (strcmp("Fly", s) == 0)
-      data->type = Fly;
-    else if (strcmp("Push", s) == 0)
-      data->type = Push;
-    else if (strcmp("Cover", s) == 0)
-      data->type = Cover;
-    else if (strcmp("Uncover", s) == 0)
-      data->type = Push;
-    else if (strcmp("Fade", s) == 0)
-      data->type = Cover;
-  }
-  obj.free();
-  
-  if (transDict->lookup("D", &obj)->isInt()) {
-    data->duration = obj.getInt();
-  }
-  obj.free();
+    ::PageTransition *pt;
+};
 
-  if (transDict->lookup("Dm", &obj)->isName()) {
-    const char *dm = obj.getName();
-    if ( strcmp( "H", dm ) == 0 )
-      data->alignment = Horizontal;
-    else if ( strcmp( "V", dm ) == 0 )
-      data->alignment = Vertical;
-  }
-  obj.free();
-  
-  if (transDict->lookup("M", &obj)->isName()) {
-    const char *m = obj.getName();
-    if ( strcmp( "I", m ) == 0 )
-      data->direction = Inward;
-    else if ( strcmp( "O", m ) == 0 )
-      data->direction = Outward;
-  }
-  obj.free();
-  
-  if (transDict->lookup("Di", &obj)->isInt()) {
-    data->angle = obj.getInt();
-  }
-  obj.free();
-  
-  if (transDict->lookup("Di", &obj)->isName()) {
-    if ( strcmp( "None", obj.getName() ) == 0 )
-      data->angle = 0;
-  }
-  obj.free();
-  
-  if (transDict->lookup("SS", &obj)->isReal()) {
-    data->scale = obj.getReal();
-  }
-  obj.free();
-  
-  if (transDict->lookup("B", &obj)->isBool()) {
-    data->rectangular = obj.getBool();
-  }
-  obj.free();
+PageTransition::PageTransition(const PageTransitionParams &params)
+{
+  data = new PageTransitionData(params.dictObj);
 }
 
 PageTransition::PageTransition(const PageTransition &pt)
 {
-  data = new PageTransitionData();
-  data->type = pt.data->type;
-  data->duration = pt.data->duration;
-  data->alignment = pt.data->alignment;
-  data->direction = pt.data->direction;
-  data->angle = pt.data->angle;
-  data->scale = pt.data->scale;
-  data->rectangular = pt.data->rectangular;
+  data = new PageTransitionData(*pt.data);
 }
 
 PageTransition::~PageTransition()
@@ -153,36 +60,36 @@
 
 PageTransition::Type PageTransition::type() const
 {
-  return data->type;
+  return (Poppler::PageTransition::Type)data->pt->getType();
 }
 
 int PageTransition::duration() const
 {
-  return data->duration;
+  return data->pt->getDuration();
 }
 
 PageTransition::Alignment PageTransition::alignment() const
 {
-  return data->alignment;
+  return (Poppler::PageTransition::Alignment)data->pt->getAlignment();
 }
 
 PageTransition::Direction PageTransition::direction() const
 {
-  return data->direction;
+  return (Poppler::PageTransition::Direction)data->pt->getDirection();
 }
 
 int PageTransition::angle() const
 {
-  return data->angle;
+  return data->pt->getAngle();
 }
 
 double PageTransition::scale() const
 {
-  return data->scale;
+  return data->pt->getScale();
 }
 bool PageTransition::isRectangular() const
 {
-  return data->rectangular;
+  return data->pt->isRectangular();
 }
 
 }

Index: poppler-page-transition.h
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-page-transition.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- poppler-page-transition.h	18 Jan 2006 21:22:12 -0000	1.2
+++ poppler-page-transition.h	27 Apr 2007 22:26:09 -0000	1.3
@@ -44,8 +44,9 @@
 
   /** \brief transition effect that shall be used
    */
+  // if changed remember to keep in sync with PageTransition.h enum
   enum Type {
-    Replace,
+    Replace = 0,
     Split,
     Blinds,
     Box,
@@ -61,15 +62,17 @@
   
   /** \brief alignment of the transition effect that shall be used
    */
+  // if changed remember to keep in sync with PageTransition.h enum
   enum Alignment {
-    Horizontal,
+    Horizontal = 0,
     Vertical
   };
   
   /** \brief direction of the transition effect that shall be used
    */
+  // if changed remember to keep in sync with PageTransition.h enum
   enum Direction {
-    Inward,
+    Inward = 0,
     Outward
   };
   



More information about the poppler mailing list