[poppler] poppler/qt: poppler-page.cc,1.5,1.6 poppler-qt.h,1.7,1.8

Albert Astals Cid aacid at freedesktop.org
Sun Jun 26 16:35:29 PDT 2005


Update of /cvs/poppler/poppler/qt
In directory gabe:/tmp/cvs-serv2991/qt

Modified Files:
	poppler-page.cc poppler-qt.h 
Log Message:
Add PageTransition class and PageTransition* Page::getTransition() const; to the qt frontend. Code almost 100% copied from xpdf code inside kpdf


Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-page.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- poppler-page.cc	4 May 2005 19:11:11 -0000	1.5
+++ poppler-page.cc	26 Jun 2005 23:35:27 -0000	1.6
@@ -1,5 +1,6 @@
 /* poppler-page.cc: qt interface to poppler
  * Copyright (C) 2005, Net Integration Technologies, Inc.
+ * Copyright (C) 2005, Tobias Koening
  *
  * 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
@@ -30,20 +31,127 @@
 
 namespace Poppler {
 
+class PageTransitionData {
+  public:
+  Object *trans;
+};
+
+//------------------------------------------------------------------------
+// PageTransition
+//------------------------------------------------------------------------
+
+PageTransition::PageTransition(const PageTransitionData &data)
+  : type(Replace),
+    duration(1),
+    alignment(Horizontal),
+    direction(Inward),
+    angle(0),
+    scale(1.0),
+    rectangular(false)
+{
+  Object obj;
+  Object *dictObj = data.trans;
+
+  if (dictObj->isDict()) {
+    Dict *transDict = dictObj->getDict();
+
+    if (transDict->lookup("S", &obj)->isName()) {
+      const char *s = obj.getName();
+      if (strcmp("R", s) == 0)
+        type = Replace;
+      else if (strcmp("Split", s) == 0)
+        type = Split;
+      else if (strcmp("Blinds", s) == 0)
+        type = Blinds;
+      else if (strcmp("Box", s) == 0)
+        type = Box;
+      else if (strcmp("Wipe", s) == 0)
+        type = Wipe;
+      else if (strcmp("Dissolve", s) == 0)
+        type = Dissolve;
+      else if (strcmp("Glitter", s) == 0)
+        type = Glitter;
+      else if (strcmp("Fly", s) == 0)
+        type = Fly;
+      else if (strcmp("Push", s) == 0)
+        type = Push;
+      else if (strcmp("Cover", s) == 0)
+        type = Cover;
+      else if (strcmp("Uncover", s) == 0)
+        type = Push;
+      else if (strcmp("Fade", s) == 0)
+        type = Cover;
+    }
+    obj.free();
+
+    if (transDict->lookup("D", &obj)->isInt()) {
+      duration = obj.getInt();
+    }
+    obj.free();
+
+    if (transDict->lookup("Dm", &obj)->isName()) {
+      const char *dm = obj.getName();
+      if ( strcmp( "H", dm ) == 0 )
+        alignment = Horizontal;
+      else if ( strcmp( "V", dm ) == 0 )
+        alignment = Vertical;
+    }
+    obj.free();
+
+    if (transDict->lookup("M", &obj)->isName()) {
+      const char *m = obj.getName();
+      if ( strcmp( "I", m ) == 0 )
+        direction = Inward;
+      else if ( strcmp( "O", m ) == 0 )
+        direction = Outward;
+    }
+    obj.free();
+
+    if (transDict->lookup("Di", &obj)->isInt()) {
+      angle = obj.getInt();
+    }
+    obj.free();
+
+    if (transDict->lookup("Di", &obj)->isName()) {
+      if ( strcmp( "None", obj.getName() ) == 0 )
+        angle = 0;
+    }
+    obj.free();
+
+    if (transDict->lookup("SS", &obj)->isReal()) {
+      scale = obj.getReal();
+    }
+    obj.free();
+
+    if (transDict->lookup("B", &obj)->isBool()) {
+      rectangular = obj.getBool();
+    }
+    obj.free();
+  }
+}
+
+PageTransition::~PageTransition()
+{
+}
+
+
 class PageData {
   public:
   const Document *doc;
   int index;
+  PageTransition *transition;
 };
 
 Page::Page(const Document *doc, int index) {
   data = new PageData();
   data->index = index;
   data->doc = doc;
+  data->transition = 0;
 }
 
 Page::~Page()
 {
+  delete data->transition;
   delete data;
 }
 
@@ -105,4 +213,17 @@
   return result;
 }
 
+PageTransition *Page::getTransition() const
+{
+  if (!data->transition) 
+  {
+    Object o;
+    PageTransitionData ptd;
+    ptd.trans = data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans(&o);
+    data->transition = new PageTransition(ptd);
+    o.free();
+  }
+  return data->transition;
+}
+
 }

Index: poppler-qt.h
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-qt.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- poppler-qt.h	2 Jun 2005 19:14:45 -0000	1.7
+++ poppler-qt.h	26 Jun 2005 23:35:27 -0000	1.8
@@ -1,5 +1,6 @@
 /* poppler-qt.h: qt interface to poppler
  * Copyright (C) 2005, Net Integration Technologies, Inc.
+ * Copyright (C) 2005, Tobias Koening
  *
  * 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
@@ -26,6 +27,7 @@
 namespace Poppler {
 
 class Document;
+class Page;
 
 /* A rectangle on a page, with coordinates in PDF points. */
 class Rectangle
@@ -41,6 +43,76 @@
     double m_y2;
 };
 
+class PageTransitionData;
+class PageTransition
+{
+friend class Page;
+public:
+  enum Type {
+    Replace,
+    Split,
+    Blinds,
+    Box,
+    Wipe,
+    Dissolve,
+    Glitter,
+    Fly,
+    Push,
+    Cover,
+    Uncover,
+    Fade
+  };
+
+  enum Alignment {
+    Horizontal,
+    Vertical
+  };
+
+  enum Direction {
+    Inward,
+    Outward
+  };
+
+
+  // Destructor
+  ~PageTransition();
+
+  // Get type of the transition.
+  Type getType() const { return type; }
+
+  // Get duration of the transition in seconds.
+  int getDuration() const { return duration; }
+
+  // Get dimension in which the transition effect
+  // occurs.
+  Alignment getAlignment() const { return alignment; }
+
+  // Get direction of motion of the transition effect.
+  Direction getDirection() const { return direction; }
+
+  // Get direction in which the transition effect moves.
+  int getAngle() const { return angle; }
+
+  // Get starting or ending scale.
+  double getScale() const { return scale; }
+
+  // Returns true if the area to be flown is rectangular and
+  // opaque.
+  bool isRectangular() const { return rectangular; }
+
+private:
+  // Construct a new PageTransition object from a page dictionary.
+  PageTransition( const PageTransitionData &data );
+
+  Type type;
+  int duration;
+  Alignment alignment;
+  Direction direction;
+  int angle;
+  double scale;
+  bool rectangular;
+};
+
 class PageData;
 class Page {
   friend class Document;
@@ -53,6 +125,12 @@
     * If r is a null Rectangle all text of the page is given
     **/
     QString getText(const Rectangle &r) const;
+
+    /**
+    * Returns the transition of this page
+    **/
+    PageTransition *getTransition() const;
+    
   private:
     Page(const Document *doc, int index);
     PageData *data;



More information about the poppler mailing list